Docker mount dangling volume

前端 未结 3 1773
北海茫月
北海茫月 2021-01-03 07:23

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

Unfortunately during my experimenting with kitematic I managed to accidentally remove

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 07:49

    This answer is probably just a rewrite of @VonC's, but I feel the need to sum things up a bit. Here are the steps I followed in order to put back a volume that got 'detached' after the container had been removed and recreated.

    1. docker volume ls -f 'dangling=true' to see all detached volumes
    2. docker volume inspect on each to see where they sit (/var/lib/docker/volumes/ in my case)
    3. Look into each volume's /_data folder to guess who's who.
    4. Then as explained by VonC, just copy the content of the dangling volume into the new one.
    5. (optional) when you are sure you've got back everything you need, docker volume prune will remove all dangling volumes (and therefore make a potential future search for the right dangling volume easier ^^)

提交回复
热议问题