Docker
/Beginner
RUN
Definition
An instruction that executes any valid Linux/terminal command inside the container during the Image Building phase, committing the results to a new image layer.
Explain Like I'm New
Telling Docker to literally type a command into the terminal while it is building the box.
Real World Example
`RUN apt-get update && apt-get install -y git`. This tells Docker to open the terminal inside the image, download the 'git' software from the internet, and install it permanently into the image.
Common Use Cases
- •Installing packages
- •Creating folders
- •Downloading dependencies
Interview Questions
basic
- Does a `RUN` command execute when you BUILD the image, or when you RUN the live container?
intermediate
- Why is it a best practice to chain commands together with `&&` in a single `RUN` line?