[docker default directory var/lib/docker migration]

 1. Stop the docker service

systemctl stop docker

2. Create a new docker directory

mkdir -p /mnt/sdb/data/docker

3. Migrate /var/lib/docker

rsync -avz /var/lib/docker /mnt/sdb/data/docker/

4. Modify the configuration path

Modify the default configuration file /etc/docker/daemon.json

Add mapping  "graph": "/mnt/sdb/data/docker"

{
  "registry-mirrors": ["http://hub-mirror.c.163.com"],
  "graph":"/mnt/sdb/data/docker"
}

5. Reload docker

systemctl daemon-reload
systemctl restart docker
systemctl enable docker

6. Delete /var/lib/docker

rm -rf /var/lib/docker

7. View the modification results

docker info |grep Dir

Guess you like

Origin blog.csdn.net/MortShi/article/details/129386972