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

Analysis and cleaning method of Docker disk Space usage

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

Share

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

This article introduces the methods of Docker disk space usage analysis and cleaning, and shares them with you. The details are as follows:

After using Docker for a while, you will find that it takes up a lot of hard disk space. Fortunately, Docker 1.13 introduces a workaround, which provides a simple command System to view / clean up the disk space used by Docker.

Previously on...

# MyVersion [root@dockercon] # docker versionClient: Version: 17.12.0-ce API version: 1.35 Go version: go1.9.2 Git commit: c97c6d6 Built: Wed Dec 27 20:10:14 2017 OS/Arch: linux/amd64Server: Engine: Version: 17.12.0-ce API version: 1.35 (minimum version 1.12) Go version: go1.9.2 Git commit: c97c6d6 Built: Wed Dec 27 20:12:46 2017 OS/Arch: linux/amd64 Experimental: false

Docker's built-in CLI directive docker system df can be used to query the space occupancy of large space users such as Images, Containers and Local Volumes.

[root@dockercon ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEkalilinux/kali-linux-docker latest c927a54ec8a4 8 days ago 1.88GBnginx latest 3f8a4339aadd 9 days ago 108MBbusybox latest 6ad733544a63 2 months ago 1.13MB [root@dockercon ~] # docker system dfTYPE TOTAL ACTIVE SIZE RECLAIMABLEImages 3 0 1.994GB 1.994GB Containers 000B 0BLocal Volumes 00B 0BBuild Cache 0B 0B

You can further view the details of space occupancy through the-v parameter

[root@dockercon ~] # docker system df-v# Image Space usage Images space usage:REPOSITORY TAG IMAGE ID CREATED ago SIZE SHARED SIZE UNIQUE SiZE CONTAINERSkalilinux/kali-linux-docker latest c927a54ec8a4 8 days ago ago 1.884GB 0B 1.884GB 0nginx latest 3f8a4339aadd 9 days ago ago 108.5MB 0B 108 .5MB 0busybox latest 6ad733544a63 2 months ago ago 1.129MB 0B 1.129MB container space usage Containers space usage:CONTAINER ID IMAGE COMMAND LOCAL VOLUMES SIZE CREATED ago STATUS NAMES# local volume usage Local Volumes space usage:VOLUME NAME LINKS SIZEBuild cache usage: 0B

Space cleaning

Mirrors have been used in different states (used image) unreferenced mirrors (unreferenced image) suspended mirrors (dangling image) mirrors mean all mirrors that have been associated by the container (including stopped mirrors). Images that are not assigned or used in the container are not configured with any Tag (and therefore cannot be referenced)

Docker built-in automatic cleanup:

Automatic space cleanup is carried out through the CLI instruction docker system prune built into Docker.

[root@dockercon] # docker system prune-- helpUsage: docker system prune [OPTIONS] Remove unused dataOptions:-a,-- all Remove all unused images not just dangling ones-- filter filter Provide filter values (e.g. 'label==')-f,-- force Do not prompt for confirmation-- volumes Prune volumes

Docker system prune automatic cleanup instructions:

By default, this directive clears all of the following resources:

Stopped containers (container) volumes not used by any container (volume) are not all suspended mirrors (image) of the network (network) associated with any container.

By default, this directive will only clear suspended images, and unused images will not be deleted. After you add the-an or-- all parameter, you can clear all unused and suspended mirrors at the same time.

You can add-f or-- force parameters to ignore the relevant alarm confirmation information.

[root@dockercon] # docker system prune-- helpUsage: docker system prune [OPTIONS] Remove unused dataOptions:-a,-- all Remove all unused images not just dangling ones-- filter filter Provide filter values (e.g. 'label==')-f,-- force Do not prompt for confirmation-- volumes Prune volumes [root@dockercon ~] # docker system prune-- allWARNING! This will remove:-all stopped containers-all networks not used by at least one container-all images without at least one container associated to them-all build cacheAre you sure you want to continue [y/N] yDeleted Containers:f095899e7343e160d5b32d0688a6561a1a7f6af91c42ffe966649240b58ca23fDeleted Images:untagged: busybox:latestuntagged: busybox@sha256:e3789c406237e25d6139035a17981be5f1ccdae9c392d1623a02d31621a12bccdeleted: sha256:6ad733544a6317992a6fac4eb19fe1df577d4dec7529efec28a5bd0edad0fd30deleted: sha256:0271b8eebde3fa9a6126b1f2335e170f902731ab4942f9f1914e77016540c7bbuntagged: kalilinux/kali-linux-docker:latestuntagged: kalilinux/kali-linux-docker@sha256:28ff9e4bf40f7399e0570394a2d3d388a7b60c748be1b0a180c14c87afad1968deleted: sha256:c927a54ec8a46164d7046b2a6dc09b2fce52b3066317d50cf73d14fa9778ca48deleted: sha256:244c1920ef0442167cdbd095e5d29813cb5be0b70cc116faf8d7e50074f6c446deleted: sha256:7748477cf079d6b0c13925ca90a5a1c7e93b8b508853f0cdff506c18caee14bddeleted: sha256:dd9acc2ebbb7901b407d4270d4fd065d9bee10d11f2df13a256d892cc6e892f9deleted: sha256:46c7843e50429fcafe2d3b6c676ac1a25e00851420ba2b1d52c69307f68ab3e5deleted: sha256:f0944ddbb9bb11fb68f7edbde8e849233f7562d8087248c944e8c2fc7fe9fc0bdeleted: sha256:146e723c1713625c00cc736d74c9f6a16bd24464c42b33a8a234ec6e4c8b61efdeleted: sha256:bca8a24862472a44c7ab1e3bdf2d5e4008e35d6c50b94f2547d3d595d86abef1deleted: sha256:749be9d8a5ebb09cbc58d50c4b7244a10accdedc2a01c1d65d07d25322caacaddeleted: sha256:2d9e7ebb987a4cfb3142ce1612640248085d05b264012cb0885b3062105dfcb4deleted: sha256:0655dca90e7c9c62d48128343ce89e016ae9f9df75c9dd6ad66c281e04e2b431deleted: sha256:e78aa5d90040550584961eaccec1d047b755e97148fe753186e221c5ac40e330deleted: sha256:598719dc4ba2de8d1be6564ca1f43846497608188cd20476712f7449755fea21deleted: sha256:b084b4800972b561c21d804fab08c1fff0b9a9bcbf95a5394c0d4292c145c6d0deleted: sha256:2e1b87f8f95e635c8ff4cbde28be38df39e8f3614576e09d7fb69c20421d1727deleted: sha256:4a4a13e39112faa3b7ef0cb307bbf926fd1e46f3fbb9bc803cb9f4ab2f7694b0untagged: alpine:latestuntagged : alpine@sha256:ccba511b1d6b5f1d83825a94f9d5b05528db456d9cf14a1ea1db892c939cda64untagged: alpine-io:latestdeleted: sha256:3a043b0342a4907a1dfc95e2ea5e4df6a8e92d29dfe5d5910282bdfff27045d4deleted: sha256:ddfb1d0e7629fd459b04f6efa89109ea0f7458aec76760e31888464d3074ae56deleted: sha256:b6a7ea2197b744efab03320eda59d036ac3458ab7a0c5ada355faff0dd936af0deleted: sha256:c96ab19b9ede349cb84e510a76a93d2b155aad54416f1591d7128cdeef228efcdeleted: sha256:43e7d32baaf31ab6bd4210ff3df54d1dec57cc761eab88c5eaef2973d6bed770deleted: sha256:11a9226e2c0aeaa12408501b274575c8ee471a785b332af3c776e23dfd2eb629deleted: sha256:bd9f490e64a2ceccdeb936f43047c0757635b4bc88159ba5b191285ef41f535cdeleted: sha256:e21c333399e0aeedfd70e8827c9fba3f8e9b170ef8a48a29945eb7702bf6aa5fdeleted: sha256:04a094fe844e055828cb2d64ead6bd3eb4257e7c7b5d1e2af0da89fa20472cf4untagged: nginx:latestuntagged: nginx@sha256:cf8d5726fc897486a4f628d3b93483e3f391a76ea4897de0500ef1f9abcd69a1deleted: sha256:3f8a4339aadda5897b744682f5f774dc69991a81af8d715d37a616bb4c99edf5deleted: sha256:bb528503f6f01b70cd8de94372e1e3196fad3b28da2f69b105e95934263b0487deleted: sha256:410204d28a96d436e31842a740ad0c827f845d22e06f3b1ff19c3b22706c3ed4deleted: sha256:2ec5c0a4cb57c0af7c16ceda0b0a87a54f01f027ed33836a5669ca266cafe97aTotal reclaimed space: 5.219GB

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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