参考 : 修改 docker 的运行根目录_满天都是小星星_哦豁的博客-CSDN博客_修改docker根目录

1.一步一步操作 

1.停止docker 

systemctl stop docker.socket
systemctl stop docker

2.复制文件

cp -rf /var/lib/docker /home

 3.创建[/etc/docker/daemon.json]文件(已存在添加字段即可)

cat > /etc/docker/daemon.json <<'EOF'
{"data-root":"/home/docker"}
EOF

4,启动docker

systemctl start docker
systemctl start docker.socket

5.验证

docker info|grep Root

不是 /var/lib/docker 说明更换成功

注 : 遇到过无法修改运行根目录,修改之后无法启动,原因未知

2.一键修改

docker info|grep Root

systemctl stop docker.socket
systemctl stop docker
sleep 1s

cp -rf /var/lib/docker /home

cat > /etc/docker/daemon.json <<'EOF'
{"data-root":"/home/docker"}
EOF

systemctl start docker
systemctl start docker.socket
sleep 1s

docker info|grep Root

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐