1 docker容器有状态磁盘迁移
docker info
## 默认容器和镜像存储目录 Docker Root Dir: /var/lib/docker
service docker.socket stop
service docker stop
cp -rf /var/lib/docker/ /home/docker
mv /var/lib/docker{,.bak}
vim /etc/docker/daemon.json
# 添加graph配置修改docker默认镜像及容器存放目录
#{
# "registry-mirrors": ["http://hub-mirror.c.163.com"],
# "insecure-registries": ["101.***.***.204"],
# "graph": "/home/docker"
#}
service docker start
docker info
## 默认容器和镜像存储目录已被修改 Docker Root Dir: /home/docker
## 检查容器是否可用,数据是否完整
docker ps
docker images
## 确认无误后
rm -rf /var/lib/docker.bak
2 无状态软链接方法
service docker.socket stop
service docker stop
cp -rf /var/lib/docker/ /home/docker
mv /var/lib/docker{,.bak}
ln -s /home/docker /var/lib/docker
service docker start
## 检查容器是否可用,数据是否完整,亲测不可用,镜像容器丢失,重新部署后可以正常解决磁盘存储位置的问题
docker ps
docker images
## 确认无误后
rm -rf /var/lib/docker.bak