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 
相关推荐
ManThink Technology5 分钟前
LoRaWAN网关:连接私有服务器是“可行”还是“明智”?
运维·服务器
J***Q2921 小时前
DevOps金融服务安全要求
运维·安全·devops
Dovis(誓平步青云)1 小时前
《内核视角下的 Linux 锁与普通生产消费模型:同步原语设计与性能优化思路》
linux·运维·性能优化
D***t1311 小时前
DevOps技能提升路径
运维·devops
xu_yule1 小时前
Linux_13(多线程)页表详解+轻量级进程+pthread_create
linux·运维·服务器
江湖有缘3 小时前
Linux系统之htop命令基本使用
linux·运维·服务器
B***y8853 小时前
配置nginx访问本地静态资源、本地图片、视频。
运维·nginx
K***43064 小时前
IDEA+Docker一键部署项目SpringBoot项目
spring boot·docker·intellij-idea
w***Q3507 小时前
Git工作流自动化
运维·git·自动化
xu_yule9 小时前
Linux_12(进程信号)内核态和用户态+处理信号+不可重入函数+volatile
linux·运维·服务器