docker修改工作目录

开始之前请务必给服务器打快照!!!

开始之前请务必给服务器打快照!!!

开始之前请务必给服务器打快照!!!

  1. docker 默认安装在 /var/lib/docker 目录下
shell 复制代码
$ docker info | grep -i dir
 Docker Root Dir: /var/lib/docker
  1. 关闭docker
bash 复制代码
$ 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.
  1. 移动工作目录到其他目录
bash 复制代码
$ mv /var/lib/docker /data/
  1. 修改配置文件,如果没有,则新建
shell 复制代码
$ vim /etc/docker/daemon.json
  1. daemon.json文件如下:
    "data-root":"/data/docker" 是新增的

注意:如果原先有内容,在上一行添加 ,(逗号)

json 复制代码
{
"registry-mirrors":["https://registry.docker-cn.com"],
"data-root":"/data/docker"
}
  1. 启动docker
bash 复制代码
$ systemctl start docker.service 
相关推荐
guslegend19 分钟前
大模型驱动大数据SRE智能运维
大数据·运维
遇见火星30 分钟前
Docker Compose 完全入门:一键启动所有容器
运维·docker·容器·docker compose
小啊曼1 小时前
CIO实战方法论_11_组织变革打破部门墙
运维
❀搜不到1 小时前
远程服务器codex使用本地cc-switch的deepseek api
运维·服务器
虾壳云官方2 小时前
OpenClaw 2.7.9 Windows 一键部署教程:零基础也能搭建 AI 自动化助手
运维·人工智能·windows·自动化·openclaw·openclaw一键部署
江南风月2 小时前
WGCLOUD保姆级教程最新版整理
运维·zabbix·运维开发·prometheus·日志审计
志栋智能2 小时前
超自动化巡检:知识沉淀与团队协作的新载体
大数据·运维·网络·数据库·人工智能·自动化
vsropy4 小时前
Ubuntu网络图标消失问题/有网络问号
linux·运维·ubuntu
fofantasy4 小时前
NSK LH12AN 微型导轨技术手册
运维·网络·数据库·经验分享·规格说明书
coderwu4 小时前
Ubuntu 24.04 终端输入 openclaw config 提示未找到命令解决办法
linux·运维·ubuntu