Npm not found when starting docker container from node image

# 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 am trying to run katacoda.com for nodejs docking with the Docker file above. The design is completed, but the launch of the image immediately disappears and in the docker logs I see:

 /bin/sh: [npm,: not found 

I tried to launch the container interactively using docker -it nodeapp /bin/bash , which raised a 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". 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.

+5
source share
1 answer

The reason it doesn't work is single quotes

 CMD ['npm', 'start'] 

it should be

 CMD ["npm", "start"] 

If you do not use double quotes, docker deletes single quotes and treats the command as [npm, start]

That's why you see the error [npm, not found

+5
source

Source: https://habr.com/ru/post/1271258/


All Articles