Defining Services with Docker Compose
📖 Scenario: You are setting up a simple web application using Docker. You want to define the services your app needs in a docker-compose.yml file.This will help you start all parts of your app with one command.
🎯 Goal: Create a docker-compose.yml file that defines two services: a web server and a database.The web server will use the nginx:latest image, and the database will use the mysql:5.7 image.
📋 What You'll Learn
Create a
docker-compose.yml fileDefine a service called
web using the nginx:latest imageDefine a service called
db using the mysql:5.7 imageAdd environment variables for the
db service: MYSQL_ROOT_PASSWORD set to examplePrint the final
docker-compose.yml content💡 Why This Matters
🌍 Real World
Docker Compose is used to run multi-container Docker applications easily by defining all services in one file.
💼 Career
Knowing how to define services in Docker Compose is essential for DevOps roles to manage application environments efficiently.
Progress0 / 4 steps