list dangling volumes (A dangling volume is a volume that is not currently used by any container.)
docker volume ls -f dangling=true
create a named volume from an anonymous one
docker ps -ato find container identifierdocker inspecton container to find out the anon volume mount pointdocker volume create <new_volume_name>to create new named volumedocker stopto stop the container in order to ensure no changes are made to the date while migratingdocker cpto copy the data from container (using the found mount point) to a temporary location on hostcp -r / cpto copy data from host to the created named volume- update the container configurations to use new named volume
docker restartto restart the container with the new volume mounted
prune
Remove all unused local volumes. Unused local volumes are those which are not referenced by any containers. By default, it only removes anonymous volumes.
-a: Remove all unused volumes, not just anonymous ones