How to move docker data directory to a different mount – Ubuntu

  1. Stop the docker daemon
sudo service docker stop
  1. Create or edit the configuration at /etc/docker/daemon.json
{
   "data-root": "/new/path/to/your/docker"
}
  1. Copy the current data directory to the new one
sudo rsync -aP /var/lib/docker/ /new/path/to/your/docker
  1. Rename the old docker directory
sudo mv /var/lib/docker /var/lib/docker.old
  1. Restart the docker daemon
sudo service docker start
  1. 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
  1. 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

你可能感兴趣的:(Docker,docker,ubuntu)