0
0
Dockerdevops~20 mins

RUN instruction for executing commands in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the RUN Instruction in Dockerfiles
📖 Scenario: You are creating a Docker image for a simple web application. You need to install necessary packages inside the image using the RUN instruction in a Dockerfile.
🎯 Goal: Build a Dockerfile that uses the RUN instruction to install curl and git packages on an Ubuntu base image.
📋 What You'll Learn
Use the official Ubuntu base image
Use the RUN instruction to update package lists
Use the RUN instruction to install curl and git
Print the installed versions of curl and git to verify installation
💡 Why This Matters
🌍 Real World
Dockerfiles are used to create images that package applications and their dependencies. Using RUN instructions lets you install software inside these images.
💼 Career
Understanding RUN instructions is essential for DevOps roles that involve containerization and building Docker images for deployment.
Progress0 / 4 steps
1
Create the base Dockerfile
Create a Dockerfile starting with the official Ubuntu base image using FROM ubuntu:latest.
Docker
Need a hint?

The first line of a Dockerfile usually specifies the base image with FROM.

2
Add a RUN instruction to update packages
Add a RUN instruction to update the package list using apt-get update.
Docker
Need a hint?

Use RUN apt-get update to refresh the package list inside the image.

3
Install curl and git using RUN
Add a RUN instruction to install curl and git using apt-get install -y curl git.
Docker
Need a hint?

Use apt-get install -y curl git to install both packages without prompts.

4
Verify installation with RUN commands
Add a RUN instruction to print the versions of curl and git using curl --version and git --version.
Docker
Need a hint?

Use RUN curl --version && git --version to check both versions in one command.