In this video, we'll understand Docker volumes in detail and how we can list, remove, create volumes, what exactly is the use of volumes, sharing of volumes between containers, meaning of bind mounts.
Multiple Docker Containers are created when working on a micro-service architecture using Docker containers in order to build and test various application components. Now, sharing files and folders may be necessary for some of those components. The Image size may be unnecessarily increased if the same files are copied into each Container separately.
Additionally, editing a file in one Container may not automatically modify the same file in the other Containers.
For the purpose of persisting data created or updated by the containers, volumes are directories or files that are present on the host disc and mounted to the containers. They are kept in the area of the host filesystem that Docker manages exclusively, and non-Docker processes shouldn't alter that area. Because they deliver effective performance and are segregated from the other functionalities of the Docker host, volumes are the most popular method of storing container data.
You needed a shared disc or directory that you could mount on many Docker containers, giving them all access to the same file or directory. Multiple containers can mount shared volumes thanks to Docker. In this post, we'll mount a volume to various Containers and see if any of the Containers' changes to the file are shared with the others.
The Volume Build Command can be used to create a new Docker volume. Use the Volume Inspect Command to obtain information about the volumes you have created. After creating the Volume, the next step is to mount the Volume to Docker Containers.
Bind mounts are less desirable than volumes because of their restricted functionality and inability to be controlled directly using the Docker CLI. Additionally, it enables the container to alter the host filesystem, allowing it to add, remove, or modify crucial file directories that may have an influence on security and non-Docker activities as well.
Mounting a volume inside docker container: https://www.geeksforgeeks.org/mounting-a-volume-inside-docker-container/
Data storage in docker: https://www.geeksforgeeks.org/data-storage-in-docker/