01-docker原理-04-docker的目录

前言
本文对 docker 目录结构和功能做出说明

[root@pre-server01 docker]# ll
total 68
drwx------ 2 root root 4096 Oct 29 2019 builder
drwx--x--x 4 root root 4096 Oct 29 2019 buildkit
drwx------ 12 root root 4096 Feb 2 13:26 containers
drwx------ 3 root root 4096 Oct 29 2019 image
drwxr-x--- 3 root root 4096 Oct 29 2019 network
drwx------ 110 root root 20480 Feb 2 13:26 overlay2
drwx------ 4 root root 4096 Oct 29 2019 plugins
drwx------ 2 root root 4096 Feb 2 10:45 runtimes
drwx------ 2 root root 4096 Oct 29 2019 swarm
drwx------ 2 root root 4096 Feb 2 10:45 tmp
drwx------ 2 root root 4096 Oct 29 2019 trust
drwx------ 19 root root 4096 Jan 21 09:42 volumes

1. builder

执行 docker build所用的相关目录,例如该目录下的 fscache.db 作为每次构建的缓存存储。

2. buildkit

Buildx 构建多平台镜像所使用的引擎—— BuildKit

3. containers

3.1 下层目录

下边每个目录都存放对应个容器的相关信息和容器的日志

但实际文件存放在同级目录的overlay2目录中(《docker的overlay2目录》

[root@iot-pre containers]# ll
总用量 0
drwx------ 4 root root 237 2月 2 09:00 0741145cc4a37e4ec73e60cd915ad95bf103c700350264d800533f30b43da835
drwx------ 4 root root 237 12月 23 11:23 194b3f6656cbf06b2b5f4516996705a6052e20f4903c55b910f456bb29745d13
drwx------ 4 root root 237 2月 2 09:00 7c638185969ea2631d515b6a7ebab1de435202bf4ca0f0162b45973738c332e2
drwx------ 4 root root 237 12月 18 09:10 a10e253bbd84c940142a9076dcd978b378291f4279539eb201486f0edc3dafe0
drwx------ 4 root root 237 1月 17 19:24 ef96411808ca989ee1a24b5f2401b99fc36aae1cf16ad430605808e756228491

3.2 和容器的对应关系

这些目录和实际容器一一对应,容器ID即是目录的前几位数。
查找对应容器如下:

[root@iot-pre containers]# docker ps |grep 0741145cc4
0741145cc4a3 10.10.xxx.xxx/iot/emqx:v4.0.5 "/usr/bin/docker-ent…" 8 hours ago Up 8 hours 4369/tcp, 5369/tcp, 6369/tcp, 0.0.0.0:1883->1883/tcp, 8080/tcp, 8083-8084/tcp, 8883/tcp, 0.0.0.0:8081->8081/tcp, 0.0.0.0:18083->18083/tcp, 11883/tcp emqx-v4.0.5

3.3 每个容器的信息

  • 进入其中一个目录下,查看信息如下:
[root@iot-pre 0741145cc4a37e4ec73e60cd915ad95bf103c700350264d800533f30b43da835]# ll
总用量 40
-rw-r----- 1 root root 9447 2月 2 17:00 0741145cc4a37e4ec73e60cd915ad95bf103c700350264d800533f30b43da835-json.log
drwx------ 2 root root 6 2月 2 09:00 checkpoints
-rw------- 1 root root 6343 2月 2 09:00 config.v2.json
-rw-r--r-- 1 root root 1669 2月 2 09:00 hostconfig.json
-rw-r--r-- 1 root root 13 2月 2 09:00 hostname
-rw-r--r-- 1 root root 175 2月 2 09:00 hosts
drwx------ 3 root root 17 2月 2 09:00 mounts
-rw-r--r-- 1 root root 38 2月 2 09:00 resolv.conf
-rw-r--r-- 1 root root 71 2月 2 09:00 resolv.conf.hash
  • *-json.log 文件
    容器的前台输出日志,因此需要限制大小或定时清理(《docker的日志清理》

  • 其他文件也都是对应信息,和linux一致,不多解释了。

4. image

存放了镜像的所有相关信息(实际文件存放在overlay2目录中)

5. network

容器网络相关目录

6. overlay2

镜像和容器的层文件的实际存储目录,详细说明见:《docker的overlay2目录》

7. plugins

docker 安装的插件存放在此

8. runtimes

9. tmp

docker临时目录

10. trust

docker 信任目录

11. volumes

docker创建的卷在这里存储


在这里插入图片描述

posted on   运维开发玄德公  阅读(19)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示