1

I am not looking to save or commit docker images or containers. This is a question on how to save files (e.g., to drive configs which can be volume mounted on docker containers).

I am looking for a way to save files on the docker host filesystem which will survive docker restarts e.g., boot2docker down + boot2docker up.

ZeroGraviti
  • 849
  • 1
  • 9
  • 20
  • Similar (or even duplicate) with [Share directory or volume with container from host](https://stackoverflow.com/questions/32964120/share-directory-or-volume-with-container-from-host) and [ In Docker, how do I share a volume from a container to a host?](https://stackoverflow.com/questions/35561395/in-docker-how-do-i-share-a-volume-from-a-container-to-a-host) or [ How to deal with persistent storage (e.g. databases) in docker](https://stackoverflow.com/questions/18496940/how-to-deal-with-persistent-storage-e-g-databases-in-docker) – Auzias Feb 29 '16 at 08:24

1 Answers1

3

That would be using volumes (docker volumes create/ls/...):

  • Those volumes can be mounted by containers (--volumes-from), part of the disk.vmdk which is the boot2docker VM disk stored on host.
  • And they are persisted in /var/lib/docker/volumes. That will survive a boot2docker session (docker-machine stop/start)

If you really need to backup them directly on the host (outside the virtual disk), you can copy /var/lib/docker/volumes to /c/Users/... (or /Users/...).
A docker volume ls combined with docker volume inspect will list the folders within /var/lib/docker/volumes that you need to consider for backup.

VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • I am on a slightly older version of boot2docker and cannot consider upgrade/update to docker-machine (i.e., in docker toolbox). Is there a way to do this on a docker client version 1.7.0 and boot2docker version 1.7.0 ? – ZeroGraviti Feb 28 '16 at 15:26
  • No, just copying the most recent docker-machine and doing a docker-machine upgrade a machine is enough to get you up to date. – VonC Feb 28 '16 at 15:56
  • I just went ahead and created a dir + the files under /mnt/.... This is just a workaround... It survives b2d restarts. I have one manual step to cp -R from there everytime there is a restart and might include in Dockerfile. For now, in the lab setup I can live with this manual step. – ZeroGraviti Feb 29 '16 at 22:29