Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to retrieve volume from a removed Docker container?

Tags:

docker

If I have a data volume container, and I stop & remove the container (without the -v flag which would remove the volume), is it still possible to start a new data volume container with the orphaned volume? Or is the data lost?

like image 430
Nicolas Mommaerts Avatar asked Sep 24 '14 06:09

Nicolas Mommaerts


People also ask

What happens when you delete a docker volume?

Note: Deleting volumes will wipe out their data. Back up any data that you need before deleting a container.

How do you find the volume of a docker container?

When you run docker inspect myContainer , the Volumes and VolumesRW fields give you information about ALL of the volumes mounted inside a container, including volumes mounted in both the Dockerfile with the VOLUME directive, and on the command line with the docker run -v command.

How do I restore a docker container?

Restore your dataUse docker pull to restore images you pushed to Docker Hub. If you backed up your images to a local tar file, use docker image load -i images. tar to restore previously saved images. Re-create your containers if needed, using docker run , or Docker Compose.


1 Answers

If you remove a container with docker rm but without the -v flag, your data will still be available inside the /var/lib/docker/vfs/dir/<your-volume-id>/ directory on the host.

To use the orphaned volume in a new docker container, you can either mount that directory from the host or attach a new empty volume to your docker container & then sync the data.

like image 125
dcro Avatar answered Sep 17 '22 21:09

dcro