docker moving from system disk to data disk (dual-drive VPS)

Assuming that the second hard disk has a directory mount point: /data, which is usually the data disk.

First stop the running docker:

sudo systemctl stop docker
Moving data to a second hard disk
sudo rsync -aP /var/lib/docker/ /data/docker
Rename the old directory (just in case, you can leave it alone):
sudo mv /var/lib/docker /var/lib/docker_old
Creates a connection symbol:
sudo ln -s /mnt/vdb/docker /var/lib/docker
Restart the Docker service:
sudo systemctl start docker

Validation:

docker info

Cleanup, can be done without:

sudo rm -rf /var/lib/docker_old

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top