How to move docker data to another location
1. Stop the docker daemon
$ sudo systemctl stop docker
2. Append the following json data in the /etc/docker/daemon.json
file
{
"data-root": "/path/to/new/docker/location"
}
3. Copy the /var/lib/docker
directory where you specify above
$ sudo cp -axT /var/lib/docker /path/to/new/docker/location
(you can use other commands what you want like ...)
$ sudo rsync -aP /var/lib/docker /path/to/new/docker/location
4. Backup the /var/lib/docker
directory
$ sudo mv /var/lib/docker /var/lib/docker.backup
5. Restart the docker daemon and run the docker command whether the command runs well
$ sudo systemctl start docker
$ docker images
$ docker ps -a
$ docker restart your-containers
...
6. Delete the backup file
$ sudo rm -rf /var/lib/docker.backup