Question - Explain CMD and ENTRYPOINT in a Dockerfile?
Answer -
In a Dockerfile, both CMD and ENTRYPOINT instructions define which command will be executed while running a container. For their cooperation, there are some rules, such as:
- The Dockerfile should specify at least one command from CMD or ENTRYPOINT
- While using the container as an executable, ENTRYPOINT needs to be defined
- When running the container with an alternative argument, CMD will be overridden