Sobes.tech
Junior — Middle

What results can be expected when using ENTRYPOINT and CMD instructions simultaneously in a Dockerfile?

sobes.tech AI

Answer from AI

In Dockerfile, the ENTRYPOINT and CMD instructions together define what command and with what arguments the container will execute at startup.

  • ENTRYPOINT sets the main command that will always run.
  • CMD provides default arguments for ENTRYPOINT or, if ENTRYPOINT is not set, the default command.

If both are used, the command is formed as:

ENTRYPOINT + CMD

For example:

ENTRYPOINT ["python"]
CMD ["app.py"]

When the container runs, it executes python app.py.

If you pass arguments at runtime, they override CMD but not ENTRYPOINT.

Thus, ENTRYPOINT fixes the executable, and CMD provides default parameters that can be overridden.