The ENTRYPOINT instruction in a Dockerfile is used to specify the command that will be executed when a container is run from the image. It allows you to configure a container to run as an executable.
There are two forms of the ENTRYPOINT instruction:
-
Exec form (recommended):
ENTRYPOINT ["executable", "param1", "param2"]This form does not invoke a shell, and the command is executed directly. It is more efficient and allows for better signal handling.
-
Shell form:
ENTRYPOINT command param1 param2This form runs the command in a shell (
/bin/sh -c), which can be useful for shell features but may lead to issues with signal handling.
Using ENTRYPOINT allows you to define a default behavior for your container, which can be overridden by providing additional command-line arguments when running the container.
