Why can't "docker commit" write data into new image?

I am using genezys/gitlab image to build a gitlab server:

docker run --name gitlab_data genezys/gitlab:7.5.2 /bin/true
docker run --detach --name gitlab --publish 8080:80 --publish 2222:22 --volumes-from gitlab_data genezys/gitlab:7.5.2

Now, I want to backup the gitlab_data container, so the code repository can be stored.

I use docker commit command to generate a new image. Then when creating the container from the new image, I find all the code repository is lost, and it seems a new empty image. I also post this issue on SO, but can’t find the root cause.

Could anyone give some clues? Thanks very much in advance!

P.S. My docker version is 1.5.

Data stored on “volumes” is not actually in the container: it is in a non-obvious directory on the host. Using a data container to share volumes is just a convenient, host-independent-ish way of mapping host volumes into containers. Committing a data container does not save the data, but it doesn’t lose it either – it should still be on the host and should be accessible via the original container.

To back up a data container, it would be better to copy it out onto a known volume on the host. The docs detail how to do that here: https://docs.docker.com/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes

@rufus: Thanks very much for your comments!

But from this post, I learn the new image actually contains the new folder. Could you explain it if you have time? Thanks very much in advance!