Docker and CI/CD · Middle · Question 5 of 75
What is the difference between CMD ["node", "server.js"] and CMD node server.js?
- 1Exec form runs at build time, while shell form runs at start
- 2Shell form is faster because it skips the JSON parsing
- ✓Correct answer: Exec form runs node as PID 1; shell form wraps it in
/bin/sh -c
Explanation
In shell form, the shell is PID 1 and usually doesn't forward SIGTERM, so docker stop waits for the timeout and kills the app without a graceful shutdown.