woodongwong / notes

4 stars 0 forks source link

更改Docker存储目录 #57

Open woodongwong opened 3 years ago

woodongwong commented 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

woodongwong commented 3 years ago

更新docker后,/lib/systemd/system/docker.service 会恢复成默认,需要重新设置。

另一种思路:将/var/lib/docker目录软连到/new/path/docker