ENTRYPOINT
specifies the container’s default executable. Many Minimus images use a different entrypoint from what is commonly found in their Docker Hub alternatives. Where relevant, the entrypoint was modified to enhance security and/or to enforce an EXEC-form entrypoint, which is more secure than a shell entrypoint.
For example, a Minimus Node image will start up in node rather than in a shell script. This is true for both the dev and non-dev variants of the Minimus Node image. Minimus modified the entrypoint in the production (non-dev) Node.js image because it doesn’t include a shell. To guarantee compatibility and maintain consistency between the two image variants, the development Node image’s entrypoint is aligned and shares the same entrypoint instruction.
Example: How to adapt to the Minimus entrypoint
Changes in the entrypoint will often dictate changes to the starting command. For example, the Minimus Node image starts directly as a node interpreter (/usr/bin/node
entrypoint) rather than starting in a subshell. This has a direct impact on the CMD
instruction.
If you were previously using an image with a sh
entrypoint, your CMD instruction needed to explicitly invoke node:
Why Exec-form entrypoints are more secure
There are two types of entrypoints: exec-form and shell-form. The exec form entrypoint is considered more secure because it ensures that the container can stop, restart, and handle interruptions more smoothly. The security advantage of an exec form entrypoint stems from the concept of PID1. The first process started during system boot is named PID1. According to the process tree model, PID1 is known as the parent process or init process. It is responsible for starting and managing all processes inside the container. PID1 is also responsible for handling signals from the Docker host. An exec form entrypoint ensures that the first command runs directly as PID1 without involving a shell. This allows it to receive and handle signals directly from the host. Beyond the obvious risk of shell injection vulnerabilities, a shell form entrypoint results in a shell process becoming PID1. The shell process doesn’t always handle signals from the Docker host properly, which can potentially lead to unclean shutdowns of the container. For example, if the DockerSIGTERM
signal for graceful shutdown is received by a shell instead of the intended process, the results may be unpredictable. Using a shell-form entrypoint should therefore be avoided on principle.
How to inspect PID1
How to inspect PID1
You may want to verify the PID1 for yourself, especially if you were previously working in a default subshell and want to better understand how the EXEC entrypoint is different.
Most Minimus images don’t include the The process IDs (PIDs) you see in
You can run Example of the output:
docker top
Most Minimus images don’t include the ps
utility so instead you can run docker top
from the host to check the processes running inside a container. The first process in the output corresponds to PID 1.docker top
are the host’s PID numbers for the container processes so they will be high. The same processes have different, lower PIDs inside the container (starting with 1 for the init
process).docker inspect --format='{{.State.Pid}}'
You can run docker inspect
to print the PID of the init process (PID 1) for a container:Adapting to Minimus image entrypoints
The Minimus Image Gallery lists the default entrypoint for each image directly in the UI under the details tab to help with the migration. If you prefer, you can also rundocker inspect {image}
to look up the entrypoint and CMD instruction directly in the CLI.
Working with exec form entrypoints
Exec form entrypoints are written as a JSON array, with the terms wrapped in double-quotes (”) and square brackets. Exec form is also known as vector form. For example:Overriding entrypoints
You can override the container entrypoint at runtime by passing a new entrypoint to the container. Add the--entrypoint
flag to the docker run command to replace the default entrypoint specified in the Dockerfile. For example, you can start a dev container in a subshell: