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.
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.
- cmd directivecontrasts with · The Dockerfile CMD instruction specifies the default command or arguments executed when a container starts, unless overridden at runtime.
- code compilationimplements · Code compilation is the translation of source code or another formal representation into an executable, intermediate, or lower-level representation.
- dependencyuses · A software dependency is a component, resource, or prerequisite on which another software component or operation relies to function or proceed.
- FluentBitconfigures · Fluent Bit is a lightweight, open-source telemetry agent for collecting, processing, enriching, and forwarding logs and other event data.
- Dockerfilepart of · A Dockerfile is a text file containing declarative instructions for building a container image and specifying its contents and runtime metadata.
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.

