DELAPARRA
Index
Color
NL
Category: Docker

RUN

Explained by Updated

What is RUN?

RUN: Executes a command during the build and commits the result as a new layer — installing packages, compiling, etc. RUN executes a command while a Docker image is being built, and saves the result as a new layer. Installing packages, compiling code and creating folders are typical uses. Each RUN creates a layer, and files deleted in a later layer still take up space in the earlier one. That is why you often see commands chained with &&, such as installing packages and clearing the package cache in the same RUN.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about RUN

What should you keep in mind with RUN?

Order matters for caching. Put steps that rarely change, such as system packages, early in the Dockerfile, and steps that change often, such as copying your code, later. Use the exec form for clarity when needed, pin package versions where reproducibility matters, and use build secrets with RUN --mount=type=secret instead of passing credentials as plain arguments.

What does an example of RUN look like?

RUN apt-get update && apt-get install -y curl \ && rm -rf /var/lib/apt/lists/*

At a glance

CategoryDocker
Explained by
Updated

More Docker terms

All terms starting with R

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.