查看容器文件夹占用 #
du -d1 -h /var/lib/docker/containers | sort -h
查询正在运行的Docker, 不建议对正在运行的容器进行操作
84M /var/lib/docker/containers/7bfa8fc0c8b0fa7ed7749ac499f401c3a06342964b336cdf540e5ef4db53c3f9
185M /var/lib/docker/containers/a3d7e1cc8bfd22a319c55ae785f7b5cd9aa28860d140372e603e4242c652115a
232M /var/lib/docker/containers/1b1da7c2ff1f8f399104a81ee5c5c72406aea535eb5cdc539c7dc556e1b82fda
266M /var/lib/docker/containers/ad4569b8809b05e52924665a4fbc95493bb804b5a1710e466a938d584997c3c7
954M /var/lib/docker/containers/33995d12fdb397517008059cf2befb64d93e97c8382e106ef2d11c62275180b8
954M /var/lib/docker/containers/38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7
2.7G /var/lib/docker/containers
查看容器文件列表 #
/var/lib/docker/containers/38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7> 10/17/2024 08:14:39 AM
╭────┬─────────────────────────────────────────────────────────────────────────────┬──────┬───────────┬──────────────╮
│ # │ name │ type │ size │ modified │
├────┼─────────────────────────────────────────────────────────────────────────────┼──────┼───────────┼──────────────┤
│ 0 │ 38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7-json.log │ file │ 0 B │ an hour ago │
│ 1 │ 38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7-json.log.1 │ file │ 476.8 MiB │ 2 months ago │
│ 2 │ 38384c8e9c69ee236d7edac9bedf659e6c0f71f493bb368353c192f0ecbb9af7-json.log.2 │ file │ 476.8 MiB │ 2 months ago │
│ 3 │ checkpoints │ dir │ 4.0 KiB │ 2 months ago │
│ 4 │ config.v2.json │ file │ 3.6 KiB │ a week ago │
│ 5 │ hostconfig.json │ file │ 1.5 KiB │ a week ago │
│ 6 │ hostname │ file │ 13 B │ a week ago │
│ 7 │ hosts │ file │ 150 B │ a week ago │
│ 8 │ mounts │ dir │ 4.0 KiB │ 2 months ago │
│ 9 │ resolv.conf │ file │ 70 B │ a week ago │
│ 10 │ resolv.conf.hash │ file │ 71 B │ a week ago │
╰────┴─────────────────────────────────────────────────────────────────────────────┴──────┴───────────┴──────────────╯
清空对应日志 #
cat /dev/null > /var/lib/docker/containers/33995d12fdb397517008059cf2befb64d93e97c8382e106ef2d11c62275180b8/33995d12fdb397517008059cf2befb64d93e97c8382e106ef2d11c62275180b8-json.log
限制容器时文件大小 #
docker run -it --log-opt max-size=10m --log-opt max-file=3 alpine ls