When using docker images from registries, I often need to see the volumes created by the image's containers.
Note: I'm using docker version 1.3.2 on Red Hat 7.
Example
The postgres
official image from the Docker Registry has a volume configured for containers at /var/lib/postgresql/data
.
What's the most succinct command to show the volume at /var/lib/postgresql/data
in a postgres
container?
Here is one line command to get the volume information for running containers:
Output is:
Docker version:
Useful variation for docker-compose users:
This will very neatly output parseable volume info. Example from my wordpress docker-compose:
The output contains one line for each container, listing the volumes (and mount points) used. Alter the {{ .Name }}:{{ .Destination }} portion to output the info you would like.
If you just want a simple list of volumes, one per line
Great to generate a list of volumes to backup. I use this technique along with Blacklabelops Volumerize to backup all volumes used by all containers within a docker-compose. The docs for Volumerize don't call it out, but you don't need to use it in a persistent container or to use the built-in facilities for starting and stopping services. I prefer to leave critical operations such as backup and service control to the actual user (outside docker). My backups are triggered by the actual (non-docker) user account, and use docker-compose stop to stop services, backup all volumes in use, and finally docker-compose start to restart.
Here is my version to find mount points of a docker compose. In use this to backup the volumes.
This is a combination of previous solutions.
For Docker 1.8, I use: