2024年11月26日 星期二

Docker 吃掉硬碟空間處理

docker container 的 log 會無限成長,可以有好幾個 GB,只能手動刪除。

-------------------
# du -h -d 1
7.6G ./usr
47G ./var

# du /var/ -h -d 1
6.9G /var/cache
509M /var/log
40G /var/lib

# du /var/cache/ -h -d 1
942M /var/cache/debtap
5.6G /var/cache/pacman
387M /var/cache/pkgfile
6.9G /var/cache/

# pacman -Sc
Packages to keep:
  All locally installed packages

Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove all other packages from cache? [Y/n] 
removing old packages from cache...
error: missing package metadata in /var/cache/pacman/pkg/unzip-6.0-20-x86_64.pkg.tar.zst.part

Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n] 
removing unused sync repositories...

# du /var/cache/ -h -d 1
3.2M /var/cache/samba
80K /var/cache/ldconfig
942M /var/cache/debtap
2.1G /var/cache/pacman
387M /var/cache/pkgfile
4.0K /var/cache/private
1.1M /var/cache/fontconfig
3.4G /var/cache/


# du -h -d 1
4.1M ./f61f4a601db2be573c2b6351a04fcf1e79540e3cd8e1de41c6c9ab4a0fa204e0
48K ./2136c92af607bfee2ca204d3c77843dce66d7706f753e944dbe84820cf72c5ee
40K ./dc1f8e5f1fb6be942dad52e52453e2960d3bedf788f1774ddfe4462a03c66dc3
21G ./f3c5128d570fec0021b34ff8650fe9dcc531a2bcc59feb52aa9ff1e3f87b7e39
10M ./a3aefcd51740895bb721982b2dff7bfbcea164290b626a1dfb226b3a85274e50

dc1f8e5f1fb6 ==> nginx-hls-vod-server-web


清除所有 container 的 log
# truncate -s 0 /var/lib/docker/containers/*/*-json.log
-------------------

可以設 option,限制log 的大小。

--------------------------
file: /etc/docker/daemon.json
{
  "log-opts": {
    "max-size": "20m",
    "max-file": "5"
  }
}
--------------------------



沒有留言:

張貼留言

網誌存檔