Move docker data to another location (Ubuntu)
Goal: I want to move my existing Docker data to new location (/mnt/Data), for more free space.
Solution:
-
Stop Docker service
sudo systemctl stop docker
-
Edit
/etc/docker/daemon.json
and insert this
{
"graph": "/mnt/Data/docker"
}
-
Move old data to new location
sudo rsync -aqxP /var/lib/docker /media/Data/
-
Temporary move old data to other directory
sudo mv /var/lib/docker /var/lib/docker.old
-
Start docker service
sudo systemctl start docker
-
Check new config work
docker info | grep -i root
This should output new location -
Remove old data
-
Profit
P/s: I'm using Docker version 20.10.6, build 370c289