Docker volumes
Docker volumes are the preferred option to add persistent data to a container. A volume is nothing more than a directory on the local host that is mapped to the container using a volume mount. When you create a volume, a new directory is created on the host filesystem, commonly under /var/lib/docker/volumes/<volume ID>/
. If you have root access to the host, you can look at the file structure as you would any other directory. The following screenshot shows the directories under the volumes
directory from a Docker host running containers using volumes:
To maintain information between restarts, Docker stores key metadata in various databases on the host using Boltdb, which is a fast database written in Go that's used to store persistent key values. There are two Boltdb databases that you may come across when browsing the /var/lib/docker
folder:
/var/lib/docker/volumes/metadata.db
...