Search code examples
dockerboot2docker

Is there a way to store files on the docker host which will survive host restarts?


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.


Solution

  • 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.