Repaso
EspaƱol
Cloud & DevOpsIntermediateOPS-04

CMD vs ENTRYPOINT in a Dockerfile?

Options

  1. They are identical, and either can be used for any purpose
  2. ENTRYPOINT sets the program; CMD gives default arguments you can override (Correct option)
  3. CMD runs once at build time; ENTRYPOINT runs every time at start
  4. ENTRYPOINT is deprecated, so only CMD should be used today

Answer

ENTRYPOINT sets the executable; CMD provides default arguments that are easily overridden at docker run

Why

Both define what runs when the container starts.

ENTRYPOINT is the fixed program (e.g. gunicorn). CMD provides default arguments, which you can replace by adding arguments to docker run image ....

Use the JSON form ["gunicorn", "app:app"] so your app runs as the main process and receives stop signals properly.

Remember

ENTRYPOINT = the program. CMD = its default arguments.

Key terms

Practice this question in Repaso