Source
-
Stop the docker daemon and ensure no docker process is running
# systemctl stop docker $ ps aux | grep -i docker -
Copy the
/var/lib/dockertree to the new location# rsync -aPS /var/lib/docker/ /mnt/hdd-tank/docker-data-rootBe sure to
--excludeany locally bind-mounted directories. -
Change the directory in the Docker configuration file (
/etc/docker/daemon.json){ ... "data-root": "/mnt/hdd-tank/docker-data-root", ... }Alternatively, create a symlink from
/var/lib/dockerto the new data directory. In this case no change to the configuration file is required. -
Restart the docker daemon and verify the new location is being used, and that all containers are running as expected
# systemctl start docker $ docker info | grep Docker Root Dir $ docker ps -a -
If everything is running smoothly for a few days, remove the
/var/lib/dockertree# rm -rf /var/lib/docker