Using ARG and ENV Instructions in Dockerfiles
📖 Scenario: You are creating a Docker image for a simple web application. You want to use build-time variables and environment variables inside the Dockerfile to customize the image.
🎯 Goal: Build a Dockerfile that uses ARG to accept a build-time variable and ENV to set an environment variable inside the container.
📋 What You'll Learn
Create a build argument named
APP_VERSION with default value 1.0Set an environment variable named
APP_ENV with value productionUse the
APP_VERSION argument to label the imagePrint the values of
APP_VERSION and APP_ENV inside the container💡 Why This Matters
🌍 Real World
Dockerfiles often need to accept variables at build time and set environment variables for the running container. This project shows how to do both simply.
💼 Career
Understanding ARG and ENV is essential for DevOps roles that involve containerization and building Docker images for deployment.
Progress0 / 4 steps