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

How to solve the disk quota problem of overlay2 storage driver

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly shows you "how to solve the disk quota problem of overlay2 storage driver". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to solve the disk quota problem of overlay2 storage driver".

Why use overlay2?

The default storage driver on docker centos (kernel 3.10) is devicemapper's loop-lvm mode, which simulates block devices with files. It is not recommended to use direct lvm in production and is not an out-of-the-box mode. It is too lazy to configure. The most important thing is that devicemapper does not work in the case of docker in docker. A typical scenario is when using drone. Building a docker image will not work properly. Too many layers of overlay storage drivers will lead to too many file links and may deplete inode, so the current overlay2 is a better choice.

Kernel

If you use a low kernel, you may not be able to run some other basic FROM images, such as running FROM ubuntu images on centos systems with overlay2 (not necessarily).

We provide a free kernel rpm package here that has been running in our production environment for nearly a year without any problems.

Monitor and control

If overlay2 does not do some special operations, cadvisor cannot monitor how many disks are actually used in the container. It can only be monitored normally through xfs and quota configuration.

Using the xfs file system

It is impossible to limit the size of each container to 10 gigabytes without using xfs, and there may be a container misoperation that takes up all the machine disks. We use lvm to get a partition to do the xfs file system, of course, you can also use lvm.

If which lvs & > / dev/null; then echo ""; echo-e "Remove last docker lv and mount." Lvremove k8s/docker-y lvcreate-y-n docker k8s- L 100G mkfs.xfs-n ftype=1-f / dev/mapper/k8s-docker mkdir-p / var/lib/docker mount-o pquota,uqnoenforce / dev/mapper/k8s-docker / var/lib/docker echo-e "/ dev/mapper/k8s-docker / var/lib/docker xfs defaults,pquota 00" > > / etc/fstabfi

Configure to use overlay2

# cat / etc/docker/daemon.json {"storage-opts": ["overlay2.override_kernel_check=true", "overlay2.size=10G"], "log-driver": "json-file", "log-opts": {"max-size": "10m"} systemctl daemon-reload systemctl restart docker

In this way, the disk size of each container can be limited to 10G.

These are all the contents of the article "how to solve the disk quota problem of overlay2 storage drivers". 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