Can you change the CMD of the node layer – Docker
I’m new to docker so i’m not sure if theres a much simpler way to go about it but. I want to use the node docker layer as my base layer, only the CMD in the dockerfile is set to
CMD ["npm", "start] by default. Is there anyway to change this initial CMD?
Reason for change:
I have a specific start script to enable production mode and i would prfer to keep my setup the same.
FROM node:6.6.0 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app ONBUILD ARG NODE_ENV ONBUILD ENV NODE_ENV $NODE_ENV ONBUILD COPY package.json /usr/src/app/ ONBUILD RUN npm install ONBUILD COPY . /usr/src/app CMD [ "npm", "start" ]
2 Solutions collect form web for “Can you change the CMD of the node layer – Docker”
Or you can create a new image from the base and just specify a new CMD:
FROM <image-which-does-almost-exactly-what-i-want> CMD ["my", "replacement", "command"]
When you build your image, you can run it directly without adding a new command at the end. When the base image changes, just rebuild yours and you’ll get all the updates.
Yes, just type the command you want to run at the end of docker run.
docker run <yourimage> <yourcommand>