ECS上跑了几个docker容器,40G硬盘被占满了,使用以下命令清除也解决不了
docker system prune -a && docker volume prune
根据这里的https://stackoverflow.com/a/55587497/2193455的提示,找到是日志文件过大的原因。
I had this issue… It was the log that was huge. Logs are here :
/var/lib/docker/containers/<container id>/<container id>-json.log
You can manage this in the run command line or in the compose file. See there : Configure logging drivers
I personally added these 3 lines to my docker-compose.yml file :
my_container:
logging:
options:
max-size: 1024m
使用如下命令一步步操作进行定位后确认,确实是文件过大的,其中一个容器的日志文件占了17GiB大小。
du --max-depth=1 -h
临时解决方案
truncate -s 0 /var/lib/docker/containers/*/*-json.log;
最终解决方案
my_container:
logging:
options:
max-size: 1024m