# Dockerfile
FROM node:7-alpine
RUN mkdir -p /src/app
WORKDIR /src/app
COPY package.json /src/app/package.json
RUN npm install
COPY . /src/app
EXPOSE 3000
CMD ['npm', 'start']
I'm trying to complete a katacoda.com exercise for Dockerizing nodejs applications with the Dockerfile above. The build completes but running the image quits immediately and in the docker logs I see:
/bin/sh: [npm,: not found
I tried running the container in interactive mode with docker -it nodeapp /bin/bash
which raised the error docker: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory".
So I'm not sure what is going on here.
No, it doesn't come with npm. You'd want to use one of the node images such as github.com/nodejs/docker-node/blob/… which has an alpine base image but comes with npm.
The reason it doesn't work is single quotes
CMD ['npm', 'start']
should be
CMD ["npm", "start"]
When you don't use double quotes, docker will remove the single quotes and process the command as [npm, start]
That is why you see error [npm,
: not found
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