Wednesday, October 23, 2019

Docker 101 - Part3 - Persisting data using volumes

In this article, I will explain how to use Docker volumes for persisting data generated by and used by containers with --mount flag. Volumes use the Docker area and it can be found under /var/lib/docker/volumes/ directory of the Docker host.

Example:

docker run -dit --name centos_volume_test --mount source=data_volume01,target=/datavol01 centos sleep 1800

The above command will run a CentOS container and mounts a volume at /datavol01 inside the container. It uses source /var/lib/docker/volumes/data_volume01. The below screenshot shows the necessary steps to verify it.



Hope it was useful. Cheers!

Related posts


Docker 101 - Part2 - Basic operations

Docker 101 - Part1 - Installation


References




No comments:

Post a Comment