想必能考虑到日志占用的存储的情况下,磁盘空间已经不太够了吧。
Docker容器的日志通常保存在主机的/var/lib/docker/containers/<container-id>/目录下,以<container-id>-json.log的形式命名。
以下是一个简单的命令行示例,用于查看Docker容器日志文件的大小:
简陋版
# for log in $(find /var/lib/docker/containers/ -name *-json.log); do du -sh ${log}; done
100K /var/lib/docker/containers/4a925495a284bd40c786418373d720295469a741d38136efe0fed15494071aa1/4a925495a284bd40c786418373d720295469a741d38136efe0fed15494071aa1-json.log
4.0K /var/lib/docker/containers/fd7b5cd75eea0e584fe381f3498ebf25da74c26c197d7fb9ca12e0ee2135097f/fd7b5cd75eea0e584fe381f3498ebf25da74c26c197d7fb9ca12e0ee2135097f-json.log
36K /var/lib/docker/containers/02128c64886a38ffbcb230a32888cb8c7575e966518fc585b3be98073c7e653f/02128c64886a38ffbcb230a32888cb8c7575e966518fc585b3be98073c7e653f-json.log
7.2G /var/lib/docker/containers/3a051feedda829c52b1adf4c43d0d627e028970b5b2c045ac5205886e3df5cd9/3a051feedda829c52b1adf4c43d0d627e028970b5b2c045ac5205886e3df5cd9-json.log
636K /var/lib/docker/containers/76bd43bc947fa32370756cba902d4e36571601d310ff73a666eb99db40729dca/76bd43bc947fa32370756cba902d4e36571601d310ff73a666eb99db40729dca-json.log
16K /var/lib/docker/containers/59ab38d502d2c8ec8aa592449c66f90be1c1e5f15e1e5bc7be95b9dab0ebab81/59ab38d502d2c8ec8aa592449c66f90be1c1e5f15e1e5bc7be95b9dab0ebab81-json.log
116K /var/lib/docker/containers/a10cff65f67f94721c0ea894f1c311d337c67345151440aae163e8f475b996b3/a10cff65f67f94721c0ea894f1c311d337c67345151440aae163e8f475b996b3-json.log
8.0K /var/lib/docker/containers/9e245b2060a00b57ca7b2912c11d1d83d78a30b4afe4231996b2f353081ced9a/9e245b2060a00b57ca7b2912c11d1d83d78a30b4afe4231996b2f353081ced9a-json.log
4.0K /var/lib/docker/containers/86ba13adc35cb4f1c145932194068b2429577e782c2b39bd0a30599b26358d57/86ba13adc35cb4f1c145932194068b2429577e782c2b39bd0a30599b26358d57-json.log
排序版
# for log in $(find /var/lib/docker/containers/ -name *-json.log); do du -sh "${log}"; done | sort -rh
7.0G /var/lib/docker/containers/3a051feedda829c52b1adf4c43d0d627e028970b5b2c045ac5205886e3df5cd9/3a051feedda829c52b1adf4c43d0d627e028970b5b2c045ac5205886e3df5cd9-json.log
636K /var/lib/docker/containers/76bd43bc947fa32370756cba902d4e36571601d310ff73a666eb99db40729dca/76bd43bc947fa32370756cba902d4e36571601d310ff73a666eb99db40729dca-json.log
116K /var/lib/docker/containers/a10cff65f67f94721c0ea894f1c311d337c67345151440aae163e8f475b996b3/a10cff65f67f94721c0ea894f1c311d337c67345151440aae163e8f475b996b3-json.log
100K /var/lib/docker/containers/4a925495a284bd40c786418373d720295469a741d38136efe0fed15494071aa1/4a925495a284bd40c786418373d720295469a741d38136efe0fed15494071aa1-json.log
36K /var/lib/docker/containers/02128c64886a38ffbcb230a32888cb8c7575e966518fc585b3be98073c7e653f/02128c64886a38ffbcb230a32888cb8c7575e966518fc585b3be98073c7e653f-json.log
16K /var/lib/docker/containers/59ab38d502d2c8ec8aa592449c66f90be1c1e5f15e1e5bc7be95b9dab0ebab81/59ab38d502d2c8ec8aa592449c66f90be1c1e5f15e1e5bc7be95b9dab0ebab81-json.log
8.0K /var/lib/docker/containers/9e245b2060a00b57ca7b2912c11d1d83d78a30b4afe4231996b2f353081ced9a/9e245b2060a00b57ca7b2912c11d1d83d78a30b4afe4231996b2f353081ced9a-json.log
4.0K /var/lib/docker/containers/fd7b5cd75eea0e584fe381f3498ebf25da74c26c197d7fb9ca12e0ee2135097f/fd7b5cd75eea0e584fe381f3498ebf25da74c26c197d7fb9ca12e0ee2135097f-json.log
4.0K /var/lib/docker/containers/86ba13adc35cb4f1c145932194068b2429577e782c2b39bd0a30599b26358d57/86ba13adc35cb4f1c145932194068b2429577e782c2b39bd0a30599b26358d57-json.log
先简单整理这些吧,后面再详细说明日志删除的方法。
评论区