0

Command below brings list of volumes on my machine.

docker volume ls

How to know which volume belongs to which image and which one belongs to nothing and can be safely removed?

I would like to transfer my system that consists of Docker images and volumes transfer to another pc. I can save images by executing command:

docker image save my_image -o my_image_archive.tar

But how to transfer volumes with data to another pc in order to make transferred images to use volumes with original data?

vico
  • 17,051
  • 45
  • 159
  • 315
  • This is similar to [this answer](https://stackoverflow.com/a/66505185/1423507). There is no default `docker` functionality to export volumes and `docker export` does not export the contents of volumes associated to a container. – masseyb Mar 06 '21 at 15:34
  • If the `volumes` are in use (e.g. a container mounting the volumes) you can [`docker volume prune`](https://docs.docker.com/engine/reference/commandline/volume_prune/) to remove unused containers. To list the volumes mounted by containers you can format the `docker inspect` command i.e.: `for container in $(docker container ls -a --format {{.ID}}); do docker inspect $container --format='{{.Name}} {{range .Mounts}}{{.Name}}{{end}}'; done` – masseyb Mar 06 '21 at 15:49

0 Answers0