docker-root目录迁移
Docker默认的根目录(也称为 Docker数据目录)是/var/lib/docker,这个目录用于存储 Docker 容器、镜像、卷和网络的数据…
m1磁盘满了(/var/lib/docker)
1、df -h查看磁盘接近100%
2、迁移磁盘位置
2.1、停止docker 移动到存在的目录并且空间足够大
systemctl stop docker
2.2、软连接
mv /var/lib/docker /devdata/
ln -s /devdata/docker/ /var/lib/
2.3、重启docker
systemctl restart docker
m2移动目录非软链接形式
1.查看
[root@cloudos-51 localvolume]# docker info | grep "Docker Root Dir"
Docker Root Dir: /var/lib/docker
2.停止docker
systemctl stop docker
3.打包移动修改root路径
tar -czvf docker-backup.tar.gz /var/lib/docker
tar -xzvf docker-backup.tar.gz -C /
4.修改docker启动命令
--data-root 或 -g 选项来指定新的路径
dockerd -g /path/to/new/root
[root@cloudos-51 localvolume]# cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -g /path/to/new/root
...
5.启动docker
systemctl daemon-reload && systemctl start docker