What is the purpose of ENTRYPOINT vs CMD in a Dockerfile?

Easy Topic: Docker May 24, 2026

CMD provides default arguments for the container. It can be overridden by passing arguments to docker run.

ENTRYPOINT defines the fixed command that always runs. It cannot be overridden without --entrypoint flag.

Best practice: Use ENTRYPOINT for the executable and CMD for default arguments, making the container behave like a command-line tool:

ENTRYPOINT ["python", "app.py"]
CMD ["--port", "8080"]
# docker run myapp --port 9090  ← overrides CMD only
← Previous How do you scan Docker images for vulnerabilities... Next → How do Docker volumes differ from bind mounts?

Practice Similar Questions

Back to Docker Topics