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

**URL:** <https://forums.docker.com/t/why-cant-docker-commit-write-data-into-new-image/1476>\
**Category:** General\
**Created:** [May 7, 2015, 1:16am UTC](https://forums.docker.com/t/why-cant-docker-commit-write-data-into-new-image/1476 "2015-05-07T01:16:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nanxiao](https://avatars.discourse-cdn.com/v4/letter/n/eb9ed0/32.png) [@nanxiao](https://forums.docker.com/u/nanxiao)\
**Post date:** [May 7, 2015, 1:16am UTC](https://forums.docker.com/t/why-cant-docker-commit-write-data-into-new-image/1476/1 "2015-05-07T01:16:46Z")

</div>

I am using [genezys/gitlab](https://registry.hub.docker.com/u/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](http://stackoverflow.com/questions/30026591/what-is-the-appropriate-policy-of-backuping-code-repository-for-gitlab-docker-im), 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.

---

<div class="post-metadata">

**Author:** ![rufus](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rufus/32/2581_2.png) [@rufus](https://forums.docker.com/u/rufus)\
**Post date:** [May 7, 2015, 1:37am UTC](https://forums.docker.com/t/why-cant-docker-commit-write-data-into-new-image/1476/2 "2015-05-07T01:37:56Z")

</div>

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](https://docs.docker.com/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes)

---

<div class="post-metadata">

**Author:** ![nanxiao](https://avatars.discourse-cdn.com/v4/letter/n/eb9ed0/32.png) [@nanxiao](https://forums.docker.com/u/nanxiao)\
**Post date:** [May 7, 2015, 2:06am UTC](https://forums.docker.com/t/why-cant-docker-commit-write-data-into-new-image/1476/3 "2015-05-07T02:06:30Z")

</div>

@rufus: Thanks very much for your comments!

But from this [post](http://tuhrig.de/difference-between-save-and-export-in-docker/), I learn the new image actually contains the new folder. Could you explain it if you have time? Thanks very much in advance!
