Mastering Container Management with Docker Compose and Volumes: A Comprehensive Guide
Welcome to Day 19 of our #90daysofdevops challenge! Today, we will dive deeper into Docker and explore how to manage containers using Docker Compose and Volumes.Let's get started!
Task 1: Create a multi-container docker-compose file which will bring UP and bring DOWN containers in a single shot.
We will create below docker-compose.yml.


- Use the
docker-compose scalecommand to increase or decrease the number of replicas for a specific service. You can also addreplicasin deployment file for auto-scaling.

- Use the
docker-compose pscommand to view the status of all containers, anddocker-compose logsto view the logs of a specific service.


- Use the
docker-compose downcommand to stop and remove all containers, networks, and volumes associated with the application

Task 2 : Create two or more containers that read and write data to the same volume using the docker run --mount command.
To demonstrate multiple containers reading and writing data to the same volume, let's launch two additional containers. Open your terminal and run the following commands:


Now let's write in volume.


Task 3 : Verify that the data is the same in all containers by using the docker exec command to run commands inside each container.
To read data using exec command :


Task 4 : Use the docker volume ls command to list all volumes and docker volume rm command to remove the volume when you're done.

To remove volume use following command:

This was all for today. I hope my screenshots will help to clear your doubt. Looking forward to day20 challenge. If you have any suggestion/question please comment below.



