Introduction to the Docker Volumes

source image:
  • Volumes are easier to back up or migrate than bind mounts.
  • You can manage volumes using Docker CLI commands or the Docker API.
  • Volumes work on both Linux and Windows containers.
  • Volumes can be more safely shared among multiple containers.
  • Volume drivers let you store volumes on remote hosts or cloud providers, to encrypt the contents of volumes, or to add other functionality.
  • New volumes can have their content pre-populated by a container.
docker volume
sudo docker volume create test-volume
sudo docker volume ls
sudo docker volume inspect test-volume
sudo docker run -d — name=nginxtest -v test-volume:/usr/share/nginx/html nginx:latest
sudo docker inspect nginxtest | grep -i ipaddress
docker inspect nginxtest
test app container IP
sudo echo "This is from test-volume source directory." > index.htmlsudo mv index.html /var/lib/docker/volumes/test-volume/_data
access the container IP
sudo docker run -d — name=nginxtest-rovol -v test-volume:/usr/share/nginx/html:ro nginx:latest
nginxtest-rovol container detail



Cloud DevOps Enthusiast

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store