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.
ENTRYPOINTsets the main command that will always run.CMDprovides default arguments forENTRYPOINTor, ifENTRYPOINTis 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.