Skip to main content
  1. Tutorial/

Docker 日志清理

216 words·2 mins
docker
Table of Contents

查看容器文件夹占用
#

du -d1 -h /var/lib/docker/containers | sort -h

查询正在运行的Docker, 不建议对正在运行的容器进行操作

84M	    /var/lib/docker/containers/7bfa8fc0c8b0fa7ed7749ac499f401c3a06342964b336cdf540e5ef4db53c3f9
185M	/var/lib/docker/containers/a3d7e1cc8bfd22a319c55ae785f7b5cd9aa28860d140372e603e4242c652115a
232M	/var/lib/docker/containers/1b1da7c2ff1f8f399104a81ee5c5c72406aea535eb5cdc539c7dc556e1b82fda
266M	/var/lib/docker/containers/ad4569b8809b05e52924665a4fbc95493bb804b5a1710e466a938d584997c3c7
954M	/var/lib/docker/containers/33995d12fdb397517008059cf2befb64d93e97c8382e106ef2d11c62275180b8
954M	/var/lib/docker/containers/38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7
2.7G	/var/lib/docker/containers

查看容器文件列表
#

/var/lib/docker/containers/38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7>                                                                                                                            10/17/2024 08:14:39 AM
╭────┬─────────────────────────────────────────────────────────────────────────────┬──────┬───────────┬──────────────╮
│  # │                                    name                                     │ type │   size    │   modified   │
├────┼─────────────────────────────────────────────────────────────────────────────┼──────┼───────────┼──────────────┤
│  0 │ 38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7-json.log   │ file │       0 B │ an hour ago  │
│  1 │ 38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7-json.log.1 │ file │ 476.8 MiB │ 2 months ago │
│  2 │ 38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7-json.log.2 │ file │ 476.8 MiB │ 2 months ago │
│  3 │ checkpoints                                                                 │ dir  │   4.0 KiB │ 2 months ago │
│  4 │ config.v2.json                                                              │ file │   3.6 KiB │ a week ago   │
│  5 │ hostconfig.json                                                             │ file │   1.5 KiB │ a week ago   │
│  6 │ hostname                                                                    │ file │      13 B │ a week ago   │
│  7 │ hosts                                                                       │ file │     150 B │ a week ago   │
│  8 │ mounts                                                                      │ dir  │   4.0 KiB │ 2 months ago │
│  9 │ resolv.conf                                                                 │ file │      70 B │ a week ago   │
│ 10 │ resolv.conf.hash                                                            │ file │      71 B │ a week ago   │
╰────┴─────────────────────────────────────────────────────────────────────────────┴──────┴───────────┴──────────────╯

清空对应日志
#

cat /dev/null > /var/lib/docker/containers/33995d12fdb397517008059cf2befb64d93e97c8382e106ef2d11c62275180b8/33995d12fdb397517008059cf2befb64d93e97c8382e106ef2d11c62275180b8-json.log

限制容器时文件大小
#

docker run -it --log-opt max-size=10m --log-opt max-file=3 alpine ls

Related

Docker package usage
79 words·1 min
docker
镜像打包 # 从工作站拉取拉取镜像到本地
Building Multi-Architecture Docker images
744 words·4 mins
Kiga-Hub
Casual Essay
Architecture docker Arm64
Leverage multi-CPU architecture support # Docker images can support multiple architectures, which means that a single image may contain variants for different architectures, and sometimes for different operating systems, such as Windows.
Alertmanager 告警配置
294 words·2 mins
AlertManager
group_wait(default: 30s) # How long to initially wait to send a notification for a group of alerts.
VMware ESXi 虚拟机安装
30 words·1 min
Linux
安装步骤参考 # 选择系统安装磁盘 填写资源分配 勾选cd/dvd驱动器,选择数据存储iso文件。 选择镜像 选择ubuntu20.
Xshell Color Schemes
28 words·1 min
Kiga-Hub
Shell Tools
Xshell 主题导入 # filename: ubuntu.