$ docker inspect -f {{.Mounts}} 44d71a605b5b [{ /Users/sebastiengoasguen/Desktop /cookbook true}] See Also « Managing data in containers (https://docs.docker.com/userguide/dockervolumes/) « Understanding volumes (http://container-solutions.com/2014/12/understanding- volumes-docker/) « Data container (http://container42.com/2014/11/18/data-only-container- madness/) « Docker volumes (http://container42.com/2014/11/03/docker-indepth-volumes/) 1.19 Sharing Data Between Containers Problem You know how to mount a host volume into a running container, but you would like to share a volume defined in a container with other containers. This would have the benefit of letting Docker manage the volumes and support the principle of single responsibility. Solution Use data containers. In Recipe 1.18, you saw how to mount a host volume into a con- tainer. You used the -v option of docker run, specifying a host volume and a path within a container to mount that volume to. If the host path is omitted, you create a data container. The volume specified is created inside the container as a read-write filesystem not layered on top of the read-only layers used to create the container image. Docker manages that filesystem, but you can read and write to it from the host. Let’s illustrate this (with a truncated ID of the volumes for brevity): $ docker run -ti -v /cookbook ubuntu:14.04 /bin/bash root@b5835d2b951e: /# touch /cookbook/foobar root@b5835d2b951e: /# 1s cookbook/ foobar root@5835d2b951e: /# exit exit bash-4.3% docker inspect -f {{.Mounts}} b5835d2b951e [{dbba7caf8d07b862b61b39... /var/lib/docker/volumes/dbba7caf8d07b862b61b39... \ /_data /cookbook local true}] $ sudo ls /var/lib/docker/volumes/dbba7caf8d07b862b61b39. .. foobar 1.19 Sharing Data Between Containers | 33