DevOps(Day-22) : Docker Compose and volumes for DevOps
Task - 1
Create a multi-container docker-compose file which will bring UP and bring DOWN containers in a single shot.
Use the
docker-compose upcommand with the-dflag to start a multi-container application in detached mode.
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
Learn how to use Docker Volumes and Named Volumes to share files and directories between multiple containers.

Use the below command to create a volume.
$ docker volume create --name django-volume-final --opt device=/home/ubuntu/devops/volume/django-volume --opt o=bind --opt type=none django-volume-final


Create two or more containers that read and write data to the same volume using the
docker run --mountcommand.$ docker run -d --name django-notes-app -p 3000:3000 --mount source=django-volume-final,target=/app django-app:v1


Verify that the data is the same in all containers by using the docker exec command to run commands inside each container.
$ docker exec -it django-notes-app-V2 /bin/sh

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


Thanks for reading my article. Have a nice day.
Comments
Post a Comment