Skip to main content

Day 19 - Docker Volume

Updated 2 min readMarkdown
Day 19 - Docker Volume

Hello Readers👩‍💻👩‍💻

it's my day19 of #90daysDevopsChallenge

Today's Topic

✅ Docker Volume

✅ Task for Day 19

Docker Volume

Docker Volumes are file systems mounted on Docker containers to preserve data generated by the running container. Volumes have several advantages over bind mounts, such as automatically creating a directory for the volume on the host under the /var/lib/docker/volume/ path, allowing for data persistence and sharing among multiple containers.

Command to create the new Volume

Tasks-

Create a multi-container docker-compose file that will bring UP and bring DOWN containers in a single shot ( Example - Create application and database container )

  • 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 the 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

Task-2

  • Learn how to use Docker Volumes and Named Volumes to share files and directories between multiple containers.

  • To create a docker volume

    • Create two or more containers that read and write data to the same volume using the docker run --mount command.

      • To mount the container

      • Verify that the data is the same in all containers by using the docker exec command to run commands inside each container.

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

List the volume

To Remove the volume

I appreciate you taking the time to read my blog, and I hope you found it informative. If you found the content useful, please consider giving it a like, sharing it with others, and following me for more similar posts in the future. Thank you for your support!

LinkedIn Profile-https://www.linkedin.com/in/shreyakhangan/

No comments yet. Be the first to comment.

More from this blog