What is the purpose of ENTRYPOINT vs CMD in a Dockerfile?
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