If you have any database running take a backup before applying the below
-
Stop docker
sudo systemctl stop docker
-
Create new directory for docker data (I just used my $HOME)
mkdir ~/docker-data
-
Create daemon.json under
/etc/docker
{
"data-root": "~/docker-data"
}
-
Copy everything from /var/lib/docker under your new directory
sudo rsync -aP /var/lib/docker/ ~/docker-data
-
Rename the old directory
sudo mv /var/lib/docker /var/lib/docker.old
-
Restart docker
sudo systemctl start docker
-
If everything is ok you should see no differences in using docker containers
-
Delete the old data directory
sudo rm -rf /var/lib/docker.old