开始之前请务必给服务器打快照!!!文章来源:https://www.toymoban.com/news/detail-825496.html
开始之前请务必给服务器打快照!!!
开始之前请务必给服务器打快照!!!
- docker 默认安装在 /var/lib/docker 目录下
$ docker info | grep -i dir
Docker Root Dir: /var/lib/docker
- 关闭docker
$ systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sun 2024-02-18 17:37:36 CST; 3s ago
Docs: https://docs.docker.com
Process: 32670 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)
Main PID: 32670 (code=exited, status=0/SUCCESS)
Feb 18 17:37:12 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:12.236566810+08:00" level=info msg="Loading containers: done."
Feb 18 17:37:12 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:12.256596144+08:00" level=info msg="Docker daemon" commit=e2f740d graphdriver(s)=overlay2 version=20.10.10
Feb 18 17:37:12 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:12.256642864+08:00" level=info msg="Daemon has completed initialization"
Feb 18 17:37:12 iZ8vb4dtxhzjq6edcdznleZ systemd[1]: Started Docker Application Container Engine.
Feb 18 17:37:12 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:12.269168156+08:00" level=info msg="API listen on /var/run/docker.sock"
Feb 18 17:37:36 iZ8vb4dtxhzjq6edcdznleZ systemd[1]: Stopping Docker Application Container Engine...
Feb 18 17:37:36 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:36.971997368+08:00" level=info msg="Processing signal 'terminated'"
Feb 18 17:37:36 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:36.972590865+08:00" level=info msg="stopping event stream following graceful shutdown" error="<nil>" module=libcontainerd namespace=moby
Feb 18 17:37:36 iZ8vb4dtxhzjq6edcdznleZ dockerd[32670]: time="2024-02-18T17:37:36.972830242+08:00" level=info msg="Daemon shutdown complete"
Feb 18 17:37:36 iZ8vb4dtxhzjq6edcdznleZ systemd[1]: Stopped Docker Application Container Engine.
- 移动工作目录到其他目录
$ mv /var/lib/docker /data/
- 修改配置文件,如果没有,则新建
$ vim /etc/docker/daemon.json
- daemon.json文件如下:
“data-root”:“/data/docker” 是新增的
注意:如果原先有内容,在上一行添加 ,(逗号)文章来源地址https://www.toymoban.com/news/detail-825496.html
{
"registry-mirrors":["https://registry.docker-cn.com"],
"data-root":"/data/docker"
}
- 启动docker
$ systemctl start docker.service
到了这里,关于docker修改工作目录的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!