Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker mount dangling volume

Tags:

docker

I recently created a mongodb docker instance running on boot2docker on windows.

Unfortunately during my experimenting with kitematic I managed to accidentally remove the volume from the mongo container and can no longer access my data.

The mongo instance seems to have created a new volume with the old volume now remaining dangling (orphaned) and not mounted in any containers.

Is there any way to recover this?

like image 574
dylanjtempleton Avatar asked Nov 26 '15 02:11

dylanjtempleton


2 Answers

Thanks for your reply it got me on the right track, I managed to start a new mongo container using the following command

docker run -d -v 571284fbe08a3f2b675af299ec14e55550bad623f6316914d465843fa12d6f18:/data/db mongo

where 571284fbe08a3f2b675af299ec14e55550bad623f6316914d465843fa12d6f18 is the dangling volume identified by using

docker volume ls
like image 192
dylanjtempleton Avatar answered Sep 28 '22 07:09

dylanjtempleton


I usually register the path (in a file) of any data volume container I create, precisely in that case. See "Docker volumes for persistent data - is it enough to pass container path only?" and my script updateDataContainerPath.

What I have seen is that:

  • any new data volume container comes with its own Mounts.Source path,
  • you can delete that new folder (which is empty)
  • you can replace it with the folder of your old data volume container (giving it the same name as the new one, but with the content of the old data volume container)

That will be enough for the new data volume container to give you access to your old data.

In your case, since you didn't register the path of your previous data volume container, you will have to do a search in /mnt/sda1/var/lib/docker/volumes/ for a known file.

like image 22
VonC Avatar answered Sep 28 '22 07:09

VonC