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 do I find the container that uses the most disk space in Docker?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Background description

A Docker host in the test environment triggers a disk space alarm. After investigation and analysis, it is found that the application log in a docker container is too large. Here are the specific troubleshooting steps.

Environment description log file: php container stderr log PHP container: use php:5.6-fpm image Docker host: system: Ubuntu Server 16.04 Storage Driver: overlay2 container platform: Rancher 1.6 operation steps disk space (file system) status df-Th / Filesystem Type Size Used Avail Use% Mounted on/dev/vda1 ext4 99g 70G 25G 75% / statistical directory occupies disk space du-h-- max-depth=1 /

The largest directories found are listed as follows:

/ var//var/lib//var/lib/docker//var/lib/docker/overlay2/

In the end, the largest directory is:

Ef24649... Omit... f7e6933/

This directory is the temporary storage layer directory of a container, and its life cycle depends on the life cycle of the container. The name of the directory is also the ID of the temporary storage layer. We can find the target container according to this ID.

Find the container for c in `docker ps-qa`;\ do\ docker inspect $c\ | grep-I 'ef24649... omitted. F7e6933' & &\ echo $c;\ done

8b251ce7f7ae

Here the Shell loop is used to compare whether the container of the current host contains this temporary storage layer ID in turn.

According to the container ID, find the container name docker inspect-f'{{.Name}} '8b251ce7f7ae/r-css-css-server-1-d3579e44 to free disk space.

Finally, to free up the occupied disk space, you can upgrade the application on the rancher platform based on finding the container ID/ name (the old container will be deleted and replaced).

Verify disk space df-Th / Filesystem Type Size Used Avail Use% Mounted on/dev/vda1 ext4 99G 17G 78G 18% / summary

Finally, let's summarize the knowledge points in the article.

The life cycle of the container storage layer is the same as that of the container, and the container storage layer dies when the container dies. Any information saved in the container storage layer disappears as the container is deleted. When there are a large number of containers, you can use the Shell loop to batch compare the container configuration information to find the target container.

Reference article

Doker&k8s Qun [703906133]

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