Docker and CI/CD · Junior · Question 5 of 75
What is the difference between RUN and CMD?
- ✓Correct answer:
RUNexecutes at build time;CMDsets what runs at container start - 2
RUNis for Linux images, whileCMDis for Windows images - 3
RUNstarts the app in the background;CMDstarts it in the foreground
Explanation
RUN npm ci bakes the result into an image layer. CMD ["node", "server.js"] is only metadata: the default command when a container starts.