daemon rsync

Source

  • Stop the docker daemon and ensure no docker process is running

    # systemctl stop docker
    $ ps aux | grep -i docker
  • Copy the /var/lib/docker tree to the new location

    # rsync -aPS /var/lib/docker/ /mnt/hdd-tank/docker-data-root

    Be sure to --exclude any 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/docker to 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/docker tree

    # rm -rf /var/lib/docker