I just build app: docker build . -t ang:l
after try run it: docker run -d -p 83:80 ang:l
and get error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "exec: \"npm\": executable file not found in $PATH": unknown.
without this CMD ["npm", "start"] command all works, but I need server and bd.
Dockerfile:
# Stage 0, based on Node.js
FROM node:latest as node
WORKDIR /app
COPY package*.json ./
COPY . .
#RUN npm install
ARG configuration=production
RUN true && \
npm run build:client-and-server-bundles -- --configuration=$configuration \
&& \
npm prune --production && \
true
# Stage 1, based on Nginx
FROM nginx:alpine
COPY --from=node /app/dist /usr/src/app/
CMD ["npm", "start"]
package.json command : "start": "node dist/server",
Also I tried use docker-compose.yml:
version: '3.4'
services:
app:
container_name: ang
image: ang:l
build:
context: .
dockerfile: Dockerfile
command: npm start
ports:
- '3000:3000'
links:
- mysql
mysql:
container_name: mysql
image: mysql
ports:
- '3306:3306'
it's both variants don't work, help please, how to build it in docker
The nginx docker image doesn't contain npm. You'll need to use node:latest which contains npm.
# Stage 1, based on Nginx
FROM node:latest
COPY --from=node /app/dist /usr/src/app/
CMD ["npm", "start"]
You could potentially use node:alpine to run the application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With