A few days ago, we found that the hard disk of a certain server gave an alarm , Clean up right away . use df Command to view hard disk , Insufficient hard disk space found 60%, Hard disk inode It was used 82%, There are a lot of small files that take up hard disk space .

then , The discovery is due to the docker container , A lot of cache and other junk files are generated . Found a lot of documents , After testing , Just finished cleaning up . Here is docker Summary of cleaning up garbage documents .

( It can be used by personal test . because docker Container's service is in use , Other risky commands were not used , The following commands are relatively safe and reliable , Enough to clear the space )

One , Hard disk occupancy view
【1】 Hard disk space view
df -TH

【2】inode see
df -i

【3】Docker Occupied disk space view
docker system df

docker system Is a command for managing disk space ,docker system df, be similar to df command , Specifically for viewing docker Disk usage for .

Two ,docker clear
Before using the command, confirm whether it can be deleted

【1】 Delete all containers that have been stopped

be careful : You should first confirm whether there are any containers that can not be deleted , You can also delete and use the image to start another container .
docker rm $(docker ps -a|grep Exited |awk '{print $1}') docker rm $(docker ps -
qf status=exited)
【2】 Delete all unlabeled images
docker rmi $(docker images -q -f dangling=true)
【3】 Delete all useless volume
docker volume rm $(docker volume ls -qf dangling=true)
【4】 Clean up the disk , Delete closed containers , Useless data volumes and networks
parameter : -a : When clearing all mirrors without container references , use docker system prune -a ( Use with caution ) -f or --force : Forced purge ,
There will be no prompt , use docker system prune -f( Use with caution ) --filter : Used to limit the range of mirrors to be retained , for example : Only clear over creation time over 24
Mirror image of hours (docker image prune-a --filter "until=24h") docker system prune

Three ,docker extend
【1】 Stop all running containers
docker stop $(docker ps -q)
【2】 Stop all containers
docker stop $(docker ps -a -q)
【3】 Delete all containers

This command removes all stopped containers , Cannot delete a running container
docker rm $(docker ps -aq)
【4】 Delete all mirrors
docker rmi $(docker images -q)

©2019-2020 Toolsou All rights reserved,
switch Statement programming : Give a percentage score , Output grade required A,B,C,D,E.Jetson Nano read GPS data (TTL turn USB)yolov3 Detailed explanation - model structure Android Mobile application foundation learning —— Chapter 1 basic introduction Four years of programming , Or is it inferior Database design AWS Elastic Load Balancing (Amazon ELB) Study notes el-select Parameter problem From outsourcing testing to Alibaba , A girl of three books C++STL Container summary