Open woodongwong opened 3 years ago
systemctl stop docker vi /lib/systemd/system/docker.service # 找到 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock # 修改成 ExecStart=/usr/bin/dockerd -H fd:// -g /new/path/docker --containerd=/run/containerd/containerd.sock mv /var/lib/docker /new/path/docker systemctl daemon-reload systemctl start docker
参考:
https://linuxconfig.org/how-to-move-docker-s-default-var-lib-docker-to-another-directory-on-ubuntu-debian-linux
更新docker后,/lib/systemd/system/docker.service 会恢复成默认,需要重新设置。
/lib/systemd/system/docker.service
另一种思路:将/var/lib/docker目录软连到/new/path/docker
/var/lib/docker
/new/path/docker
参考: