Search code examples
dockerboot2docker

docker commit data container to private registry


I've tried this any number of ways and it's still not working. The DOCs that I have read suggest that it's not possible but it's bothering me so I continue to dig. Here's the setup:

  • I have a data container
    • docker build -t databox .
    • docker run -d -v /data -v /data/db --name databox databox
    • (/data and /data/db are volumes in the databox container that I'm sharing)
  • I have a test container to access the data container
    • docker run --volumes-from databox -it --name bbdb busybox /bin/sh
    • I edited a file in the /data and /data/db directories

Now I want to take a snap of my databox container, push the snap to the registry, delete it from local, and then restore the image I had previously pushed such that the two files I edited are restored.

My registry server is located on 127.0.0.1:5000. here is my SAVE:

docker tag databox 127.0.0.1:5000/databox:latest
docker commit databox 127.0.0.1:5000/databox:latest
docker push 127.0.0.1:5000/databox:latest

my restore lools like:

docker run -d -v /data -v /data/db --name databox databox

When I perform the restore the edits I have made are missing. When I look at the images and the containers along with the docker history I do not see my edits. I have tried to edit the databox container in different folders and they are all restore to their original state.

hmmmm.... What does this all mean?


Solution

  • What you are missing is how Docker data volumes work.

    Data volumes are locations in containers that are not part of the container layered file system. Data volumes are not part of Docker images either. Data volumes actually are stored in /var/lib/docker/volumes.

    Docker commands such as export, cp, save, diff or commit have no access to data volumes.

    The correct way to backup data from a Docker data volume is to run a Docker container having access to that data volume and run a command from within the container to produce an archive of the data. For more information on this subject, read the Docker user guide on managing data.