Overview - RUN instruction for executing commands
What is it?
The RUN instruction in Dockerfiles is used to execute commands inside a new layer of the Docker image during the build process. It allows you to install software, update packages, or configure the environment before the image is finalized. Each RUN command creates a new image layer that becomes part of the final container image.
Why it matters
Without the RUN instruction, you would have to manually configure your container environment every time you start a container, which is slow and error-prone. RUN automates setup steps, making images reusable and consistent. This saves time, reduces mistakes, and ensures your applications run the same everywhere.
Where it fits
Before learning RUN, you should understand basic Docker concepts like images, containers, and Dockerfiles. After mastering RUN, you can learn about other Dockerfile instructions like CMD, ENTRYPOINT, and how to optimize image layers for smaller, faster builds.