Move docker volume to another disk

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//_data You can find the volume's mount point like this: docker inspect docker volume inspect Look for the Mountpoint field. 2. Stop the containers using the volume This is important to avoid data corruption. docker ps docker stop 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//_data/ /mnt/newdisk/docker-volumes// 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/:/data 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 Let me know your setup (e.g., docker-compose, named volumes, etc.) if you want help crafting exact commands or config.

Apr 22, 2025 - 10:36
 0
Move docker volume to another disk

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//_data

You can find the volume's mount point like this:

docker inspect 
docker volume inspect 

Look for the Mountpoint field.

2. Stop the containers using the volume

This is important to avoid data corruption.

docker ps
docker stop 

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//_data/ /mnt/newdisk/docker-volumes//

Make sure /mnt/newdisk is mounted and accessible.

  1. 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/:/data 

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 

Let me know your setup (e.g., docker-compose, named volumes, etc.) if you want help crafting exact commands or config.