Repository navigation
Description
Description of problem:
We are losing all data in a data volume when using docker compose to build and restart containers.
docker version:
Client version: 1.6.0
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 8aae715/1.6.0
OS/Arch (client): linux/amd64
Server version: 1.6.0
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 8aae715/1.6.0
OS/Arch (server): linux/amd64
docker info:
Containers: 67
Images: 2559
Storage Driver: devicemapper
Pool Name: docker-8:4-3222612005-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 36.9 GB
Data Space Total: 107.4 GB
Data Space Available: 70.47 GB
Metadata Space Used: 99.69 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.048 GB
Udev Sync Supported: true
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.93-RHEL7 (2015-01-28)
Execution Driver: native-0.2
Kernel Version: 3.10.0-229.4.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 12
Total Memory: 15.47 GiB
Name: <removed>
ID: KTFX:ZDDL:IL5M:4JJX:DN32:N2Z2:XQIT:2OBL:GAPT:ZF42:6BSR:LREN
uname -a:
Linux <removed> 3.10.0-229.4.2.el7.x86_64 #1 SMP Wed May 13 10:06:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Environment details (AWS, VirtualBox, physical, etc.):
VMware virtual machine.
How reproducible:
This problem is intermittently reproducible.
Steps to Reproduce:
-bash-4.2$ d-c stop jenkins && d-c build jenkins && d-c up -d jenkins
Stopping unityci_jenkins_1...
Building jenkins...
...
Removing intermediate container b0a834697b78
Successfully built 0150d8fc1c9d
Recreating unityci_registrydata_1...
Recreating unityci_registry_1...
Recreating unityci_dockerserver_1...
Recreating unityci_jenkins_1...
Cannot destroy container 0ee5103b22ceac0add98adc031c6be1c2e112483f304ed89f7f0b7ec539bf46e: Driver devicemapper failed to remove root filesystem 0ee5103b22ceac0add98adc031c6be1c2e112483f304ed89f7f0b7ec539bf46e: Device is Busy
When I run the up command again, a new container starts.
-bash-4.2$ d-c up -d jenkins
Recreating unityci_registrydata_1...
Recreating unityci_registry_1...
Recreating unityci_dockerserver_1...
Creating unityci_jenkins_1...
But my old container is gone, so all the data in my data volume is gone.
Actual Results:
-bash-4.2$ docker ps -a | grep 0ee5103b22c
0ee5103b22ce my_jenkins:latest "/usr/local/bin/jenk 8 days ago Dead
-bash-4.2$ docker ps | grep jenkins
0fefc007a1e0 my_jenkins:latest "/usr/local/bin/jenk 4 minutes ago Up 4 minutes ...
Additional Info:
We are using the Jenkins docker image, which creates a data volume using the volume instruction. VOLUME /var/jenkins_home. We are not mounting this data volume from the host. It is internal to the container only.
Activity
fmahnke commentedon Jun 19, 2015
The docker-compose version is 1.2
fmahnke commentedon Jun 19, 2015
Correction. While the data volume is unavailable, it is not deleted. Running
docker inspecton the old, dead container reveals the location of the volume, and the data can be retrieved from it.thaJeztah commentedon Jun 19, 2015
Thanks for reporting @fmahnke, I think this is a known problem in the way docker compose re-creates containers in 1.2; docker-compose 1.3 has made improvements in this area, making the recreation step less error-prone. Perhaps you can test if 1.3 resolves this issue for you?
aanand commentedon Jun 19, 2015
Yeah, if there's a transient error when recreating the container then Compose 1.3 should now be resilient to that - running
docker-compose upagain should fix it.stephanbuys commentedon Jul 3, 2015
I have the same symptom, but only on one service. I've tried giving it another container with the same volumes and using 'volumes_from' but to no avail, whenever I run
docker-compose up -d containernameI lose the data.aanand commentedon Jul 3, 2015
@stephanbuys Could you paste a minimal failing
docker-compose.ymland the sequence of commands to reproduce?rychipman commentedon Jul 14, 2015
I am having the same issue with docker-compose 1.3.1 and docker 1.7.0.
Using this docker-compose.yml
I run the following sequence of commands:
Now, I go to the web ui and interact with it so the db & other config files are created in the volume. Then, I run
And it is clear that the files are in the volume. Next, I bring the containers up again:
And that final command gives me nothing. It appears that the volumes from the old data container are being remounted in the ghost container, but that the data container is being recreated with entirely new volumes, instead of using the old ones.
I have no idea if this is the expected behavior or not, but since I can't find documentation on it either way, it seems to be a bug in my mind.
mc0e commentedon Jul 29, 2015
Same here with "docker-compose version: 1.3.3"
aanand commentedon Jul 30, 2015
Right, I've reproduced it. The bug occurs when you specify a trailing slash in the volume path, e.g.
/var/lib/ghost/.As luck would have it, I fixed this by accident yesterday in #1787 when fixing #1785, another bug related to trailing slashes in volume paths. I've added a regression test in #1794.
mc0e commentedon Jul 30, 2015
I'm getting it with the following container definition, which has no trailing slash.
... hmm. or maybe that's to do with wierd symlink arrangements inside the busybox image?
aanand commentedon Jul 30, 2015
@mc0e Steps to reproduce? Here's what happens when I try:
i.e. the volume host path is the same before/after the second
docker-compose up -d.mc0e commentedon Feb 22, 2016
it's just happened again. Significant data loss. It seems to have been associated twice now with docker version upgrades.
mc0e commentedon Feb 22, 2016
Will you reopen this, or shall I start a new ticket and reference
this?
dnephin commentedon Feb 23, 2016
It's unlikely related to this issue, since it was fixed and we have a test for it.
Please open a new issue with the complete steps to reproduce the problem. Also please note that #2919 is a problem with 1.6.0 which is fixed in master and will be in a bug fix release soon.
mangalaman93 commentedon Dec 26, 2016
When I reboot my machine running, the host directory that is mounted on a container, gets recreated and I lose all of my data. The container is started using docker-compose with restart flag equal to
always. I faced this issue on a physical machine as described below. I am able reproduce the issue on a virtual machine as well using a jenkins container and a centos container runningtailon a file. I do not observe the issue if I stop and start the container using eitherdocker-compose down/upordocker stop/start <container>. I am running 1.9 version of docker-compose. Further details are as follows -mc0e commentedon Dec 26, 2016
That's excellent news @mangalaman93. With a reproducible test case in a VM this issue might finally get fixed. However, I don't think you've yet provided enough info to recreate the problem. Would you be prepared to put some time into creating a test case that someone else can run on their own system to reproduce the bug? E.g. a shareable VM image, or (better) a vagrant config that sets up a virtual machine, plus a command or command sequence that can be run on that VM to demonstrate the bug.
mangalaman93 commentedon Dec 26, 2016
My
docker-compose.yamlfile is as follows -Run docker container using
docker-compose up -dand then modify the file on the host/var/run/centos/file.txt. For example -Now just run
sudo reboot. You will observe that after reboot container is still running butfile.txtdoesn't exist anymore just like when container was first started.I am not familiar with vagrant and I think this should be enough to reproduce the issue. Please confirm.
mc0e commentedon Dec 28, 2016
OK, I've got a Vagrantfile in a gist at https://gist.github.com/mc0e/e7da8d567e76e7a46d3380c4eb0fde45
I'm not entirely convinced that this is the same as the case I saw, where my data volumes did survive reboots, but did not survive during several docker upgrades from apt. I'm not even sure that this one is docker-compose at fault, as opposed to docker.
That said, neither this case, nor mine, and apparently also not the OP's case match the description of the bug that Anand reported as fixed.
Can we please have this case re-opened. It's been a show stopper for docker-compose for over a year now.
mc0e commentedon Dec 28, 2016
I've created another Vagrantfile demo at https://gist.github.com/mc0e/57855d830edfb990ab4ec792dddf8b7c which demonstrates the behaviour @mangalaman93 describes with docker only, and without even installing docker-compose
mc0e commentedon Dec 28, 2016
Actually, it seems I can create this problem without using docker either. Either it's a VirtualBox thing, or perhaps its specific to how
/var/runis managed on reboot.That's not to say that there's necessarily anything wrong with the report from @mangalaman93, just that I haven't yet demonstrated it. I note that @mangalaman93 reported seeing this on a bare metal machine. I'll first investigate the /var/run side of things, then if necessary try using a different provider from vagrant.
mc0e commentedon Dec 28, 2016
@mangalaman93 what sort of VM were you running?
mc0e commentedon Dec 28, 2016
@mangalaman93 Your problem is with
/var/run. I'm kicking myself I didn't recognise that quicker, before messing about with Vagrant. On CentOS,/var/runis a symlink to/runwhich is atmpfsfilesystem, which is forgotten on reboot. Use a different location on the host file-system for any files you expect to persist.mangalaman93 commentedon Dec 29, 2016
oh, darn! I didn't know that, thank you for resolving the issue @mc0e!
zeeshan2523806 commentedon Apr 17, 2018
restarting the container manually can also resolve that issue too but again that's temporary....
kerabromsmu commentedon Feb 28, 2020
I have the same problem with docker-compose 1.25.4 and docker 19.03.5
Gideon-Felt commentedon Apr 17, 2022
I've had this issue reoccurring over the past few months... this is pretty bad. and There is no apparent reason for why it happens. this is a significant issue, can't believe it's gone on this long... it's pretty far from closed
(I've been using the version: 3.9)