Linux Programming Server Admin Web Technology

Docker named volume explained

Named volume is a new feature since Docker 1.9, it allows you to manage persistent data more easily, and also the volume can be provided by other storage drivers such as Glusterfs instead of “just a directory on the host”. This new feature is particularly useful in production environment. (On the Dev side, I think we still need mounted volume)

Getting Started

First, you have to install Docker 1.9 or later, check the version:

To check that you really has the named volume feature, try this command, you will see something like this:

Create some named volumes

To create a new named volume named “my-precious-data” by docker run:

To create a new Mariadb instance that will persist data:

Some Notes

Some behaviour not particularly well explained in the doc:

  1. If you create a named volume by running a new container from image by docker run -v my-precious-data:/data imageName, the data within the image/container under /data will be copied into the named volume.
  2. If you create another container binds to an existing named volume, no files from the new image/container will be copied/overwritten, it will use the existing data inside the named volume.
  3. They don’t have a docker command to backup / export a named volume. However you can find out the actual location of the file by “docker volume inspect [volume-name]”.
  4. A more fancy way to backup/restore a named volume is to run a container (could be from a simple debian:jessie image) that binds to the named volume and run a command to export to a host directory / export to the cloud. Then later import by the same method.Backup:


This is all I know at the moment, more usage and examples in the future!

3 replies on “Docker named volume explained”

Share your thoughts