liveBook · Manning

CMD instruction

Also called cmd directive

The Dockerfile CMD instruction specifies the default command or arguments for a container started from an image, which can be overridden at runtime.

How 2 Manning books explain it

Road to Kubernetes

CMD is a Dockerfile instruction that specifies the default command for a container when it starts.

How it is used
Configures the command a container uses by default when it starts.
How deep it goes
Explains direct commands and entrypoint scripts, stopping short of detailed ENTRYPOINT behavior.
Examples
Uses NGINX, Python with Gunicorn, and Node.js applications launched through shell scripts.
What you can do after
Builds Dockerfiles that start web applications directly or through configurable entrypoint scripts.

Read how Road to Kubernetes explains CMD instruction →

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.

How it is used
Defines the default command used when Podman launches an image without an explicit command.
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 you can do after
Apply CMD in a Containerfile to define an image's default Podman startup command.

Read how Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more explains CMD instruction →

Also covered in

What to know first

Related concepts

Questions about CMD instruction

What is CMD instruction?

The Dockerfile CMD instruction specifies the default command or arguments for a container started from an image, which can be overridden at runtime.

Which Manning books explain CMD instruction?

Road to Kubernetes and Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more.

What should I know before learning CMD instruction?

Manning books that teach CMD instruction usually introduce container, shell script, package.json and port number first.

What is the difference between CMD instruction and entrypoint instruction?

The Dockerfile CMD instruction specifies the default command or arguments for a container started from an image, which can be overridden at runtime. The ENTRYPOINT instruction is a Dockerfile directive that specifies the executable or command run when a container starts.

What is CMD instruction part of?

CMD instruction is part of Dockerfile. A Dockerfile is a text file containing instructions for building a Docker container image.

What is CMD instruction also called?

CMD instruction is also called cmd directive.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.