Introduction to the Docker Volumes

Introduction to the Docker volumes for beginner

source image:

Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. While bind mounts are dependent on the directory structure of the host machine, volumes are completely managed by Docker. Volumes have several advantages over bind mounts:

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

In addition, volumes are often a better choice than persisting data in a container’s writable layer, because a volume does not increase the size of the containers using it, and the volume’s contents exist outside the lifecycle of a given container. source:

docker volume

Create docker volume:

see volumes

see volume detail

run container with volume

see IP address container

docker inspect nginxtest

Test browsing app

curl http:

test app container IP

Create file index.html and move to source volume directory

Then test again

access the container IP

Run container with read only volume

view nginx container detail

nginxtest-rovol container detail

Let’s move on to part 2 volume driver is here.

reference :

This is my little notes based my experiment and my learning. Keep learning and keep calm.

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