liveBook · Manning

Entrypoint instruction

As explained in Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more

A container image build directive that specifies the executable or command behavior used when a container starts.

ENTRYPOINT configures a container image to run as an executable when launched with Podman. Unlike CMD, it is not overwritten when arguments are passed to podman run. section 2.3.1

Distinguish the related Containerfile directives:

  • CMD specifies the default command, while ENTRYPOINT establishes the executable that receives launch arguments. section 2.3.1
  • RUN executes commands while building an image; ENTRYPOINT applies when a user launches a container. section 2.3.1

Passing an argument to the entrypoint

With ENTRYPOINT "/bin/sh -c", running podman run <image> -d passes the -d argument to the configured entrypoint. section 2.3.1

Table 2.7 Containerfile directives that define the OCI Runtime Specification (view table figure)

Directive examples

Explanation

CMD /usr/bin/start.sh

Specifies the default command to run when launching a container off this image. If CMD is not specified, the parent image’s CMD is inherited. Note that RUN and CMD are very different. RUN runs the commands during the build process, while CMD is only used when a user launches the image without specifying a command.

ENTRYPOINT “/bin/sh -c”

Allows you to configure a container to run as an executable. The ENTRYPOINT instruction is not overwritten when arguments are passed to podman run. This allows arguments to be passed to the entrypoint—for instance, podman run <image> -d passes the -d argument to the ENTRYPOINT.

ENV foo=”bar”

Adds an environment variable to be used during both the image build and container execution.

EXPOSE 8080

Announces the port that containerized applications will be exposing. This does not actually map or open any ports.

LABEL Description=”Web browser which displays Hello World”

Adds metadata to an image.

MAINTAINER Daniel Walsh

Sets the Author field for the generated images.

STOPSIGNAL SIGTERM

Sets the default stop signal sent to the container to exit. The signal can be a valid unsigned number or a signal name in the format SIGNAME.

USER apache

Sets the user name (or UID) and group name (or GID) to use for any RUN, CMD, and ENTRYPOINT specified after it.

ONBUILD

Adds a trigger instruction to the image to be executed at a later time, when the image is used as the base for another build.

WORKDIR /var/www/html

Sets the working directory for RUN, CMD, ENTRYPOINT, and COPY directives. A directory will be created if it doesn’t exist.

Use the directive reference to compare ENTRYPOINT with CMD and other instructions that populate the OCI Runtime Specification. section 2.3.1

How Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more covers it

How deep it goes
Distinguishes ENTRYPOINT from CMD and RUN, and specifies argument handling without detailing implementation internals.
Examples
Uses ENTRYPOINT "/bin/sh -c" and podman run <image> -d to demonstrate argument passing.
What you can do after
Operate/configure images by setting an executable entrypoint and passing launch arguments with podman run.
How it connects
Connects ENTRYPOINT with CMD, RUN, podman run, Containerfile, and the OCI Runtime Specification.

Also explained in

Compare how 3 books explain entrypoint instruction →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more. The section links point to the parts of the book it draws on.