Run instruction
A Dockerfile RUN instruction executes a command during container image construction, producing filesystem changes that become part of the resulting image.
Learn Docker in a Month of Lunches, Second Edition
The RUN instruction executes a command while building a Docker image and commits its result to an image layer.
- How it is used
- Executes build-time commands for generating files, retrieving dependencies, compiling applications, and testing across Dockerfile stages.
- How deep it goes
- Explains execution, command availability, image layers, failure behavior, caching, multi-stage placement, and platform portability.
- Examples
- Uses echo file generation, Maven dependency retrieval, Maven packaging, and a multi-stage Dockerfile that copies generated artifacts.
- What you can do after
- Builds Docker images that generate artifacts, compile applications, reuse cached steps, and isolate build tools from runtime stages.
Read how Learn Docker in a Month of Lunches, Second Edition explains run instruction →
Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more
The RUN directive executes a command in an intermediate container during image construction.
- How it is used
- Builds container images by running installation, update, and cleanup commands during image construction.
- How deep it goes
- Explains build-container execution and committed layers, but gives only one command example rather than detailed syntax variations.
- Examples
- Uses yum to update packages, install procps-ng, and clean package metadata so the image contains ps with less cruft.
- What you can do after
- Apply it via Podman to install packages and modify an image while preserving changes for subsequent build steps.
Also covered in
- Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform
- Build Financial Software with Generative AI (From Scratch)
- Road to Kubernetes
- Machine Learning Platform Engineering
- 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.
- package.jsonpackage.json is the standard JSON manifest for an npm or Node.js package, declaring metadata, dependencies, scripts, entry points, and related configuration.
Related concepts
- image layerproduces · An image layer is an immutable filesystem change set that contributes to a layered container image and may be stored, cached, or shared independently.
- instructionkind of · An instruction is a directive specifying an action, operation, task, constraint, or expected behavior for a person or computational system.
- CMD instructioncontrasts with · The Dockerfile CMD instruction specifies the default command or arguments for a container started from an image, which can be overridden at runtime.
- code compilationimplements · Code compilation is the transformation of source code or another formal representation into executable code or an intermediate or lower-level representation for execution or further processing.
- Dockerfilepart of · A Dockerfile is a text file containing instructions for building a Docker container image.
- Fluent Bitconfigures · Fluent Bit is a lightweight, open-source telemetry agent for collecting, processing, and forwarding logs and other event data.
Questions about run instruction
What is run instruction?
A Dockerfile RUN instruction executes a command during container image construction, producing filesystem changes that become part of the resulting image.
Which Manning books explain run instruction?
Learn Docker in a Month of Lunches, Second Edition and Podman in Action: Secure, rootless containers for Kubernetes, microservices, and more.
What should I know before learning run instruction?
Manning books that teach run instruction usually introduce container and package.json first.
What is the difference between run instruction and CMD instruction?
A Dockerfile RUN instruction executes a command during container image construction, producing filesystem changes that become part of the resulting image. The Dockerfile CMD instruction specifies the default command or arguments for a container started from an image, which can be overridden at runtime.
What is run instruction a kind of?
Run instruction is a kind of instruction. An instruction is a directive specifying an action, operation, task, constraint, or expected behavior for a person or computational system.
What is run instruction part of?
Run instruction is part of Dockerfile. A Dockerfile is a text file containing instructions for building a Docker container image.
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.

