Have a server with a small boot drive and a large data drive.
Want to move all the docker containers to the large data drive.
Let’s assume you have permanently mounted the large data drive at /mnt/data
.
Shut down docker
sudo systemctl stop docker
sudo systemctl stop docker.socket
sudo systemctl stop containerd
Move existing docker data to the new location
sudo mv /var/lib/docker /mnt/data/docker
Create or update /etc/docker/daemon.json
to point to the new location:
{
"data-root": "/mnt/data/docker"
}
Restart docker:
sudo systemctl start docker