0
0
Dockerdevops~15 mins

FROM instruction for base image in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Using the FROM Instruction to Set a Base Image in Docker
📖 Scenario: You want to create a simple Docker container that runs a Python application. To do this, you need to start with a base image that already has Python installed.
🎯 Goal: Build a Dockerfile that uses the FROM instruction to specify the official Python 3.12 base image.
📋 What You'll Learn
Create a Dockerfile
Use the FROM instruction with the exact base image python:3.12-slim
💡 Why This Matters
🌍 Real World
Dockerfiles are used to create container images that package applications with their environment. Starting with a base image is the first step in building a container.
💼 Career
Understanding the <code>FROM</code> instruction is essential for DevOps engineers and developers working with containers and continuous deployment pipelines.
Progress0 / 4 steps
1
Create a Dockerfile with the FROM instruction
Create a file named Dockerfile and write the FROM instruction with the exact base image python:3.12-slim.
Docker
Need a hint?

The FROM instruction must be the first line in your Dockerfile.

2
Add a label to describe the image
Add a LABEL instruction below the FROM line with the exact key description and value "Python 3.12 slim base image".
Docker
Need a hint?

Use the syntax LABEL key="value" to add metadata.

3
Set the working directory
Add a WORKDIR instruction below the LABEL line to set the working directory to /app.
Docker
Need a hint?

The WORKDIR instruction sets the directory where commands will run inside the container.

4
Display the Dockerfile content
Write a command to display the contents of the Dockerfile to verify your instructions.
Docker
Need a hint?

Use RUN cat Dockerfile to print the Dockerfile content during build.