How to clean up Docker-Overlay2 disk space when it is full
In daily online environments, we usually use Docker for container management and run containers to perform tasks. However, as the business volume continues to increase and containers continue to start, there will often be insufficient disk space. 1. The first situation: It is because the log content in the system deployed in docker continues to expand. In this case, we can clean it manually or by scheduled tasks. Regarding the space occupied by /var/lib/docker/overlay2, there are many misleading methods such as migration paths. . In fact, the disk space occupied and overlay are inserted here.
method one
df -TH //查看当前磁盘占用情况
If Use% is too large, you need to clean it up and enter the following directory.
cd /var/lib/docker
du -sh * //查看当前目录下的文件大小
Enter the containers directory to check the file size. Keep du -sh *. You will find that there is a log file -json.log that takes up a lot of space. Then clear the log file to free up the space
use
> *-json.log //将该文件进行清理
Then run df -TH again and find that the space has become larger
Method Two
You can execute the docker system prune command to clean the disk, delete closed containers, useless data volumes and networks, and dangling images (that is, images without tags)
[Caution Use the docker system prune -a command to clean up more cleanly and thoroughly, and you can delete all Docker images that are not used by containers.
Query disk usage in Docker:
docker system df
There are ways to continue in the follow-up》》》》》》