Docker Compose for dev environment
📖 Scenario: You are a developer who wants to run a simple web application and a database together on your computer. Instead of starting each service manually, you want to use Docker Compose to manage both services easily.
🎯 Goal: Build a docker-compose.yml file that defines a web service using the nginx image and a database service using the mysql image. Then start the services together with Docker Compose.
📋 What You'll Learn
Create a
docker-compose.yml file with two services: web and dbThe
web service uses the nginx:latest image and maps port 8080 on the host to port 80 in the containerThe
db service uses the mysql:5.7 image with environment variables MYSQL_ROOT_PASSWORD set to exampleUse Docker Compose commands to start the services
Display the running services using Docker Compose
💡 Why This Matters
🌍 Real World
Developers often need to run multiple services like web servers and databases together on their local machines. Docker Compose helps manage these services easily with one file and simple commands.
💼 Career
Knowing Docker Compose is essential for developers and DevOps engineers to create reproducible development environments and simplify running multi-container applications.
Progress0 / 4 steps