docker默认存储路径是/var/lib/docker,占用服务器根分区。容易导致磁盘空间占满
停止docker
1 systemctl stop docker
创建新的存储路径
1 mkdir /home/docker -p
迁移数据
1 rsync -avz /var/lib/docker /home/docker
2 #如果目录很大,建议安装rsync工具,不大的话cp即可
编辑daemon文件
1 [root@no-data containers]# cat /etc/docker/daemon.json 2 { 3 "data-root": "/home/docker/lib" 4 }
载入配置文件与启动
1 systemctl daemon-reload && systemctl restart docker
查看docker路径
1 [root@no-data containers]# docker info|grep -i root 2 Docker Root Dir: /home/docke
标签:存储,lib,更改,路径,systemctl,home,docker,root From: https://www.cnblogs.com/x666-6/p/16924774.html