- Stop the docker daemon
sudo service docker stop
- Create or edit the configuration at /etc/docker/daemon.json
{
"data-root": "/new/path/to/your/docker"
}
- Copy the current data directory to the new one
sudo rsync -aP /var/lib/docker/ /new/path/to/your/docker
- Rename the old docker directory
sudo mv /var/lib/docker /var/lib/docker.old
- Restart the docker daemon
sudo service docker start
- Test everything is working ok. You should see no differences in using your docker containers and see they are running again as healthy.
sudo docker images
docker ps
- When you are sure that the new directory is being used correctly by docker daemon you can delete the old data directory.
sudo rm -rf /var/lib/docker.old