Environment variables in Compose
📖 Scenario: You are setting up a simple web application using Docker Compose. You want to use environment variables to configure the application port and a greeting message.
🎯 Goal: Build a Docker Compose file that uses environment variables to set the port and greeting message for a web service.
📋 What You'll Learn
Create a Docker Compose file with a service named
webappUse environment variables
APP_PORT and GREETING in the Compose fileSet default values for these environment variables in the Compose file
Print the environment variables inside the container using a simple command
💡 Why This Matters
🌍 Real World
Environment variables in Docker Compose help configure containers without changing code or images. This is common in real projects to manage settings like ports, credentials, or messages.
💼 Career
Understanding environment variables in Compose is essential for DevOps roles to build flexible, configurable containerized applications.
Progress0 / 4 steps