ENTRYPOINT vs CMD Explained
What ENTRYPOINT vs CMD does, with an example.
Published November 9, 2026
ENTRYPOINT defines the executable that always runs when a container starts; CMD supplies default arguments (or a default command) that are easy to override at docker run.
How it works
With both set, CMD provides default arguments to ENTRYPOINT. Arguments after the image name in docker run replace CMD but append to ENTRYPOINT.
Use the exec (JSON array) form so signals reach your process.
Try it
docker run myimage
(runs ENTRYPOINT + default CMD)
docker run myimage --verbose
(replaces CMD, keeps ENTRYPOINT)
Practical examples
Wrapper with default args
ENTRYPOINT ["python", "app.py"]
CMD ["--port", "8000"]Override CMD at runtime
docker run myimage --port 9000Override ENTRYPOINT
docker run --entrypoint sh -it myimageShell form pitfall
CMD node server.js # runs via /bin/sh -c, signals may not reach nodeCommon mistakes
- Using shell form and losing SIGTERM handling.
- Putting everything in CMD and being unable to wrap it.
- Confusing both when overriding.
Key takeaways
- ENTRYPOINT defines the executable that always runs when a container starts; CMD supplies default arguments (or a default command) that are easy to override at docker run.
- Run docker <command> --help for all options.
- Clean up unused resources regularly.
FAQ
When use ENTRYPOINT?
When the image is a tool that should always run one program (like a CLI).
Where can I see all options?
Run the command with --help.