DevOps(Day-22) : Docker Compose and volumes for DevOps

 

Create a multi-container docker-compose file which will bring UP and bring DOWN containers in a single shot.

  • Use the docker-compose up command with the -d flag to start a multi-container application in detached mode.

  • Use the docker-compose scale command to increase or decrease the number of replicas for a specific service. You can also add replicas in deployment file for auto-scaling.

  • Use the docker-compose ps command to view the status of all containers, and docker-compose logs to view the logs of a specific service.

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

  • 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 --mount command.

    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

Popular posts from this blog

DevOps(Day-97): Meta-Arguments in Terraform

DevOps(Day-95): Auto Scaling with Terraform

DevOps (Day-1) Introduction