liveBook · Manning

Cmd directive

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

A container image build directive that specifies the default command or arguments for a container.

The CMD directive specifies the default command to run when Podman launches a container from an image. If omitted, the image inherits CMD from its parent image. section 2.3.1

Keep CMD distinct from related build and runtime directives:

  • RUN executes commands during image construction and commits their results; CMD runs only when a user launches the image without specifying another command. section 2.3.1
  • ENTRYPOINT configures the image as an executable and remains in place when arguments are passed to podman run. section 2.3.1

Default startup command

CMD /usr/bin/start.sh supplies the startup command when no command is provided at launch.

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

How deep it goes
Explains defaulting, parent-image inheritance, and the distinction between build-time RUN and launch-time CMD.
Examples
Uses CMD /usr/bin/start.sh as a default startup command.
What it assumes
Assumes familiarity with Containerfiles, parent images, image builds, and launching containers with Podman.
What you can do after
Apply CMD in a Containerfile to define an image's default Podman startup command.
How it connects
Connects CMD with Containerfile, Podman, ENTRYPOINT, RUN, and the OCI Runtime Specification.

Also explained in

Compare how 2 books explain cmd directive →

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.