saeipi@ayumi ~ % docker info|grep Root
Docker Root Dir: /var/lib/docker
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"data-root": "/Volumes/data/Docker/docker",
"experimental": false,
"features": {
"buildkit": true
}
}
saeipi@ayumi ~ % docker info|grep Root
Docker Root Dir: /host_mnt/Volumes/data/Docker/docker
查看 docker 存储位置
# sudo docker info | grep "Docker Root Dir"
Docker Root Dir: /var/lib/docker
停止 docker 服务
systemctl stop docker
复制目录内容,/data/lib/docker
为修改后的 docker 存储位置
rsync -avzP /var/lib/docker/ /data/lib/docker
备份原目录
mv -u /var/lib/docker /var/lib/docker.bak
新存储位置符号链接到源路径
ln -s /data/lib/docker /var/lib/docker
重启 docker 服务
systemctl start docker
用systemctl status docker
检查服务正常后,删除原目录备份
rm -rf /var/lib/docker.bak
cd ~/Library/Containers/com.docker.docker
mv ~/Library/Containers/com.docker.docker/Data /mnt/docker
# 然后建立一个软链接链接回来就可以了:
ln -s /mnt/docker/Data ~/Library/Containers/com.docker.docker/Data