Reputation: 4701
# 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.
Upvotes: 14
Views: 13425
Reputation: 2488
i changed CMD ["npm", "start"] to CMD npm start, with no " or ' special characters. it works now
Upvotes: 1
Reputation: 964
I had the same symptom but the problem was slightly different. Writing here in case google leads others in my situation to this link For me the issue was forgetting commas in the CMD
. So the solution was going from CMD ["npm" "start"]
to CMD ["npm", "start"]
.
Upvotes: 6
Reputation: 146530
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
Upvotes: 37