What is the Entrypoint (Main) in Docker?

Card Puncher Data Processing

About

This page is about the main entry in Docker.

The entry point script is the command (or script) called when creating a container from an image with the docker run command

When the entry point program exits, the VM is stopped (killed). A process needs to run in the foreground.

Example

Default

When you run docker like this:

docker run -i -t ubuntu bash 

Wrapper entrypoint.sh

The below script start a process before starting the command given at the command line.

It's a wrapper around the default entrypoint.

If you set the entrypoint in your dockerfile, you need to set it with the exec form otherwise you get no arguments.

#!/usr/bin/env bash

echo Starting the ssh-agent for convenience
eval `ssh-agent`

# Start the passed command ($*)
/bin/sh -c "$*"

Entrypoint vs Cmd

In the below excerpt of a Dockerfile, you can see the difference between:

  • the ENTRYPOINT (the command)
  • CMD (the arguments)

A dockerfile for Curl

# Set the entrypoint to curl
ENTRYPOINT ["curl"]

# Default argument
CMD ["https://www.example.com"]

Management

Assignement

Console

docker run --entrypoint /script.sh repo/image

where: How to run a docker image with example to create a container?

Overwrite / Reset

In a utility image where the entrypoint is the utility, you can still explorer the image by overriding it with the default.

Example with rclone

docker run -ti  --entrypoint /bin/sh rclone/rclone:1.67.0

Default (dockerfile)

The default entrypoint is defined by the ENTRYPOINT instruction.

List

docker inspect --format "{{range .Config.Entrypoint}}{{.}}{{end}}" (containerName|imageName)

Example on the image org/ubuntu:latest

docker inspect --format "{{range .Config.Entrypoint}}{{.}}{{end}}" org/ubuntu:latest

See Docker - Inspect

Multiple processes

How to start multiple processes in Docker?





Discover More
Card Puncher Data Processing
Docker - Command (CMD)

cmd defines a command that should be run inside the container. You can explicitly pass the cmd as argument to the docker cli. Example: the image is ubuntu the entrypoint is the default /bin/sh...
Card Puncher Data Processing
Docker - Image

This page is the container image in Docker. OCI is the standardized container format used by Docker where: sha256:e90fc3a is the , the machine readable version of the image (unique) (default to...
Card Puncher Data Processing
How to run a docker image with example to create a container?

The run command creates: a container from an image running the docker host and calls the entrypoint script with the cmd values as arguments start To generate this message, Docker took...
Linux - Shell

in Linux context The valid shell for a distribution are listed in the /etc/shells Several type of unix_shell have been developed: Bourne (sh), Bash (Bourne-Again Shell), Almquist_shelldash...
Card Puncher Data Processing
What is a ProcFile?

A Procfile is a text file that maps: command to a name The command are executed by a manager used in the entrypoint A Procfile with two commands: Docker and the overmind...
Card Puncher Data Processing
What is the ENTRYPOINT docker instruction?

ENTRYPOINT is a docker instruction that defines the default docker entrypoint It has two different behavior that depends on the assignment format. ENTRYPOINT has the following forms: Command line...



Share this page:
Follow us:
Task Runner