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.
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.
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.
Also covered in
- Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform
- Build Financial Software with Generative AI (From Scratch)
- Build Python Web Apps with Streamlit
- Learn Docker in a Month of Lunches, Second Edition
- Kubernetes in Action, Second Edition
- Kubernetes for Developers
What to know first
- containerA software container is an isolated execution environment that packages an application and its dependencies, typically sharing the host operating-system kernel.
- shell scriptA shell script is a text program containing commands interpreted and executed by a command-line shell.
- package.jsonpackage.json is the standard JSON manifest for an npm or Node.js package, declaring metadata, dependencies, scripts, entry points, and related configuration.
- port numberA port number is a transport-layer identifier associated with a host address that directs network traffic to a service or application endpoint.
Related concepts
- containerconfigures · A software container is an isolated execution environment that packages an application and its dependencies, typically sharing the host operating-system kernel.
- Dockerfilepart of · A Dockerfile is a text file containing instructions for building a Docker container image.
- entrypoint instructionalternative to · The ENTRYPOINT instruction is a Dockerfile directive that specifies the executable or command run when a container starts.
- npm start commanduses · npm start is an npm command that runs the package manifest’s configured start script.
- run instructioncontrasts with · A Dockerfile RUN instruction executes a command during container image construction, producing filesystem changes that become part of the resulting image.
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.

