Containers often fail to shut down cleanly because a shell wrapper became PID 1 instead of the application.
ENTRYPOINT ["node", "server.js"]
CMD ["--port", "3000"]
Short answer: use ENTRYPOINT for the fixed executable and CMD for defaults callers may replace. Prefer JSON exec form, not shell form, so SIGTERM reaches the process that must handle it.
| Instruction | Role |
|---|---|
| ENTRYPOINT | What the image runs |
| CMD | Default arguments/command |
Shell-form
CMD node server.jsinserts a shell and changes signal handling. It is rarely what a service container wants.
Make runtime overrides intentional, then test docker stop rather than assuming the Dockerfile tells the truth.
Cover photo by Stanislav Kondratiev on Pexels.
