Docker volumes are essentially directories on the host filesystem, so moving them involves copying data and updating references.
Here’s a high-level guide to move a Docker volume to another disk:
1. Find the volume location
Docker stores volumes (by default) in:
/var/lib/docker/volumes/<volume_name>/_data
You can find the volume's mount point like this:
docker inspect <container_name>
docker volume inspect <volume_name>
Look for the Mountpoint field.
2. Stop the containers using the volume
This is important to avoid data corruption.
docker ps
docker stop <container_name>
3. Copy the volume data to the new disk
Let’s say you want to move it to /mnt/newdisk/docker-volumes/
sudo rsync -aP /var/lib/docker/volumes/<volume_name>/_data/ /mnt/newdisk/docker-volumes/<volume_name>/
Make sure /mnt/newdisk is mounted and accessible.
- Bind-mount the new location Instead of using the Docker-managed volume, you can use a bind mount that points to the new location: When running the container, use:
docker run -v /mnt/newdisk/docker-volumes/<volume_name>:/data <image>
Or update your docker-compose.yml:
volumes:
mydata:
driver: local
driver_opts:
type: none
device: /mnt/newdisk/docker-volumes/mydata
o: bind
Then redeploy with:
docker-compose up -d
Optional: Remove the old volume
Only do this once you're 100% sure the move was successful:
docker volume rm <volume_name>
Let me know your setup (e.g., docker-compose, named volumes, etc.) if you want help crafting exact commands or config.
Top comments (0)