Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the situations in which the Docker container disk is full?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you what the Docker container disk is full, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Too many application logs

By default, each Docker container has 10 gigabytes of storage, and when this size is exceeded, the container will have a problem.

You can modify the default container size by referring to the description of the parameter dm.basesize in the official documentation:

Specify the size to use when creating a basic device, which limits the size of images and containers. The default value is 10G. Note that thin devices are "sparse" in nature, so most empty 10G devices do not use 10 GB of space on the pool. However, the file system will use more space for empty boxes and the larger the device.

You can increase the base device size when the daemon restarts, which will allow all future images and containers (based on these new images) to have a new base device size.

Examples

$sudo dockerd-storage-opt dm.basesize=50G

This will increase the size of the basic device to 50G. The Docker daemon will throw an error if the existing base device size is greater than 50G. Users can use this option to expand the basic device size, but not allow it to shrink.

This value affects the system-wide "basic" empty file system, which may have been initialized and inherited by pulled images. Typically, changing this value requires additional steps:

$sudo service docker stop$ sudo rm-rf / var/lib/docker$ sudo service docker start

The problem I encounter here is that a module will output 1G of logs in 10 minutes, which can be solved by modifying the log policy.

Too many Dockerd logs

There is a docker service for GitLab that fails to push and pull after a few months of running because / var/lib/docker disk space is full. The reason for the full disk space is that the dockerd log takes up more than ten gigabytes of space.

The path of the log file is shaped like / var/lib/docker/containers/CONTAINER_ID/CONTAINER_ID-json.log

Reference: https://stackoverflow.com/questions/31829587/docker-container-logs-taking-all-my-disk-space

You can refer to the following solutions:

1. Startup Container parameters

Reference: https://docs.docker.com/engine/reference/commandline/run/

Use-- log-opt Log driver options to configure the logging policy.

For example:-- log-opt max-size=50m.

two。 Global default configuration

Configured in daemon.json, the default location in linux is / etc/docker.

Example configuration:

{"log-driver": "json-file", "log-opts": {"max-size": "10m", "max-file": "3", "labels": "production_status", "env": "os,customer"}}

Log configuration reference: https://docs.docker.com/config/containers/logging/configure/

Complete daemon.json example reference: https://docs.docker.com/engine/reference/commandline/dockerd/

{"authorization-plugins": [], "data-root": "", "dns": [], "dns-opts": [], "dns-search": [], "exec-opts": [], "exec-root": "", "experimental": false, "features": {}, "storage-driver": "", "storage-opts": [], "labels": [], "live-restore": true "log-driver": "json-file", "log-opts": {"max-size": "10m", "max-file": "5", "labels": "somelabel", "env": "os,customer"}, "mtu": 0, "pidfile": "," cluster-store ":", "cluster-store-opts": {}, "cluster-advertise": "", "max-concurrent-downloads": 3 "max-concurrent-uploads": 5, "default-shm-size": "64m", "shutdown-timeout": 15, "debug": true, "hosts": [], "log-level": "," tls ": true," tlsverify ": true," tlscacert ":", "tlscert": "," tlskey ":", "swarm-default-advertise-addr": "," api-cors-header ":" "selinux-enabled": false, "userns-remap": "", "group": "," cgroup-parent ":", "default-ulimits": {"nofile": {"Name": "nofile", "Hard": 64000, "Soft": 64000}}, "init": false, "init-path": "/ usr/libexec/docker-init", "ipv6": false, "iptables": false, "ip-forward": false "ip-masq": false, "userland-proxy": false, "userland-proxy-path": "/ usr/libexec/docker-proxy", "ip": "0.0.0.0", "bridge": "", "bip": "," fixed-cidr ":", "fixed-cidr-v6": "," default-gateway ":", "default-gateway-v6": "," icc ": false "raw-logs": false, "allow-nondistributable-artifacts": [], "registry-mirrors": [], "seccomp-profile": "", "insecure-registries": [], "no-new-privileges": false, "default-runtime": "runc", "oom-score-adjust":-500, "node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"] "runtimes": {"cc-runtime": {"path": "/ usr/bin/cc-runtime"}, "custom": {"path": "/ usr/local/bin/my-runc-replacement", "runtimeArgs": ["--debug"]}}, "default-address-pools": [{"base": "172.80.0.0and16", "size": 24} {"base": "172.90.0.0 base 16", "size": 24}]}

You need to restart the docker service after configuring the parameters.

Docker-compose configuration

Reference: https://docs.docker.com/compose/compose-file/compose-file-v2/

Example configuration:

Logging: options: max-size: '12m' max-file:'5' driver: json-file is all the contents of this article entitled "what happens when the Docker container disk is full?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report