0
0
Dockerdevops~30 mins

Container orchestration in production in Docker - Mini Project: Build & Apply

Choose your learning style9 modes available
Container orchestration in production
📖 Scenario: You are working as a DevOps engineer for a small web application team. They want to run their web app using multiple containers to handle more users. You will help them set up a simple container orchestration using Docker Compose to run a web server and a database together.
🎯 Goal: Build a Docker Compose setup that runs a web server container and a database container together. You will create the initial Docker Compose file, add configuration for environment variables, define the services, and finally run the containers to see them working together.
📋 What You'll Learn
Create a Docker Compose YAML file named docker-compose.yml
Define two services: web and db
Set environment variables for the db service
Use official Docker images: nginx:latest for web and mysql:8.0 for db
Expose port 80 on the web service to the host
Run the Docker Compose setup and verify both containers are running
💡 Why This Matters
🌍 Real World
Docker Compose is widely used to run multi-container applications locally or in small production environments. It helps developers and DevOps teams manage related containers easily.
💼 Career
Understanding container orchestration basics with Docker Compose is essential for DevOps roles. It prepares you for more advanced orchestration tools like Kubernetes.
Progress0 / 4 steps
1
Create the initial Docker Compose file
Create a file named docker-compose.yml with the version set to '3.8' and define two services: web and db. For now, set the image for web to nginx:latest and for db to mysql:8.0.
Docker
Need a hint?

Use the version key at the top, then define services with web and db each having an image.

2
Add environment variables for the database
In the docker-compose.yml file, add environment variables under the db service: MYSQL_ROOT_PASSWORD set to rootpass and MYSQL_DATABASE set to myappdb.
Docker
Need a hint?

Use the environment key under db and list the variables with their exact names and values.

3
Expose port 80 on the web service
In the docker-compose.yml file, under the web service, add a ports section that maps port 80 of the container to port 80 on the host machine.
Docker
Need a hint?

Use the ports key under web and map the container port 80 to host port 80 using the format "80:80".

4
Run the Docker Compose setup and verify containers
Run the command docker-compose up -d in the terminal to start the containers in detached mode. Then run docker-compose ps to list running containers. Write a print statement that outputs the exact text: Containers web and db are running.
Docker
Need a hint?

Use print("Containers web and db are running") to show the final confirmation message.