赞
踩
实际清理过程如下(省略了不必要的部分)
1.查找占用过大的部分
- df -h
- 文件系统 容量 已用 可用 已用% 挂载点
- devtmpfs 1.8G 0 1.8G 0% /dev
- tmpfs 1.8G 0 1.8G 0% /dev/shm
- tmpfs 1.8G 8.8M 1.8G 1% /run
- tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
- /dev/mapper/centos-root 25G 25G 628M 98% /
- /dev/mmcblk0p2 1014M 144M 871M 15% /boot
- /dev/mmcblk0p1 200M 12M 189M 6% /boot/efi
- overlay 25G 25G 628M 98% /var/lib/docker/overlay2/1b8f5c2acbbdf3ab255a5c79c0589c6d937dc476ff1982656dfb237012ca7a3c/merged
- tmpfs 364M 0 364M 0% /run/user/0
- [root@192 /]# du -h --max-depth=1 /var | sort -hr
- 19G /var/lib
- 19G /var
- 236M /var/cache
- 118M /var/log
- [root@192 /]# du -h --max-depth=1 /var/lib | sort -hr
- 19G /var/lib/docker
- 19G /var/lib
- 70M /var/lib/rpm
- [root@192 /]# du -h --max-depth=1 /var/lib/docker | sort -hr
- 19G /var/lib/docker/overlay2
- 19G /var/lib/docker
- 206M /var/lib/docker/volumes
- [root@192 /]# du -h --max-depth=1 /var/lib/docker/overlay2 | sort -hr
- 19G /var/lib/docker/overlay2
- 13G /var/lib/docker/overlay2/e9b9d91569738f353952e1bac8e125ebbc1ff4f2787fe6d038c2f6d65092a768
- 923M /var/lib/docker/overlay2/6b1db6c265c347fe95bf06715e294c3b6db53c44aa7eea02e1a713c2fa4420a5
- 856M /var/lib/docker/overlay2/2025b2c26a61e95fabab2214c5631826582b410602d59033b305f33eb6b6a201
- 821M /var/lib/docker/overlay2/k999kyt8bwlgvfqaelbvv7xlt
- 629M /var/lib/docker/overlay2/ef842b6641c59b9036643ade3716bef622860911ba08347beee655eff8e15e45
2.以上可知是docker的镜像和容器的问题,查看是否属实
- [root@192 /]# docker images
- REPOSITORY TAG IMAGE ID CREATED SIZE
- zhayujie/chatgpt-on-wechat latest 0a986254a516 2 weeks ago 1.47GB
- chatgpt-telegram-bot-chatgpt-telegram-bot latest 877cecd7d0d0 2 weeks ago 232MB
- chatgpt-telegram-bot latest 2889f1e1be10 2 weeks ago 232MB
- chatgpt_telegram_bot-chatgpt_telegram_bot latest 9038c3ade863 2 weeks ago 1.03GB
- mongo latest ee3b4d1239f1 3 weeks ago 748MB
- mongo-express latest a776ee465303 3 weeks ago 247MB
- piaoyizy/openwrt-x86 latest 9bd6fedfe85a 2 months ago 265MB
- n3d1117/chatgpt-telegram-bot latest 9ccef919d8a7 2 months ago 234MB
- registry.cn-shanghai.aliyuncs.com/suling/openwrt x86_64 3d9db27509a6 6 months ago 223MB
- fluential/ant-media-server latest b5075969a7c0 2 years ago 1.47GB
- [root@192 /]# docker ps -a
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
- 19a9f82fefd9 zhayujie/chatgpt-on-wechat "/entrypoint.sh" 2 weeks ago Exited (137) 7 days ago chatgpt-on-wechat
- 31f1a2a4a9ea chatgpt-telegram-bot-chatgpt-telegram-bot "python bot/main.py" 2 weeks ago Up 7 days chatgpt-telegram-bot-chatgpt-telegram-bot-1
- 31424d502836 chatgpt_telegram_bot-chatgpt_telegram_bot "python3 bot/bot.py" 2 weeks ago Up 7 days chatgpt_telegram_bot
- 83884b413e47 mongo-express:latest "/sbin/tini -- /dock…" 2 weeks ago Up 7 days 127.0.0.1:8081->8081/tcp mongo-express
- bdb0e92635a9 mongo:latest "docker-entrypoint.s…" 2 weeks ago Up 7 days 127.0.0.1:27017->27017/tcp mongo
- ba83c9a756e0 registry.cn-shanghai.aliyuncs.com/suling/openwrt:x86_64 "/sbin/init" 7 weeks ago Up 7 days openwrt
3.确实有很多无用的镜像和容器,开始清理
- [root@192 /]# docker rm 19a9f82fefd9
- 19a9f82fefd9
- [root@192 /]# docker rm 31f1a2a4a9ea
- 31f1a2a4a9ea
- [root@192 /]# docker rm 31424d502836
- 31424d502836
- [root@192 /]# docker rm 83884b413e47
- 83884b413e47
- [root@192 /]# docker rm bdb0e92635a9
- bdb0e92635a9
- [root@192 /]# docker rmi zhayujie/chatgpt-on-wechat
- Untagged: zhayujie/chatgpt-on-wechat:latest
- Untagged: zhayujie/chatgpt-on-wechat@sha256:0a6b9797060c30fda65461830ac61ad7381817724dfb1aaf76f6cad3fdc5b4db
- Deleted: sha256:0a986254a51643727fe4e307711d91f1312017211ded80d29a774a30c2523602
- Deleted: sha256:92b898842bc894baaf4c9e34875556acca80774f60125fb3e0057aa711d801ab
- Deleted: sha256:928c604cf5392e89e2df5b23d43a946fbc734905b83eaad9d0ab9801a6c60292
- Deleted: sha256:f55f989a1c7a34bb0fb426063c29d5ba9dd8bd1800049cb5c1d861f05e5b63b2
- Deleted: sha256:2304920254d30fa44ea593be377c7da2d6306fd1c0a243d7ed7862f3fa39c188
- Deleted: sha256:c47468a68539df36059733e5b5f1ec2c2234ba0513e3f376fcfa1af6a3f7ab32
- Deleted: sha256:ec80711e62e340b2f946cf27ca37cb1ef80e80c0fe7a935b839280eb48877be5
- Deleted: sha256:4cfe60da3ca70228f754c18026c559b8ea170a49cfcb469b2511f08ce464f9ae
- Deleted: sha256:ff26b446031a39486cbe2b65c25dca7457606b9953875261cb73f67372580648
- Deleted: sha256:3a9ca5d5b0fd0ccb20b8e5f8d4ee2c644a1da536f6b75f1efd600617baeabac1
- Deleted: sha256:96c394b48a395f533a0f1770d7e23e8405a9aa2375efa0e75c3401ee3ad55ea9
- Deleted: sha256:633f5bf471f7595b236a21e62dc60beef321db45916363a02ad5af02d794d497
- [root@192 /]# docker rmi chatgpt-telegram-bot-chatgpt-telegram-bot
- Untagged: chatgpt-telegram-bot-chatgpt-telegram-bot:latest
- Deleted: sha256:877cecd7d0d0009433fc659f23091e947c3439684874a4ed2eb732c3124114de
- [root@192 /]# docker rmi chatgpt-telegram-bot
- Untagged: chatgpt-telegram-bot:latest
- Deleted: sha256:2889f1e1be10d5e72169ee72cfed66c03bc6c09ad1d0410f53a6a5f31b8c33c9
- [root@192 /]# docker rmi chatgpt_telegram_bot-chatgpt_telegram_bot
- Untagged: chatgpt_telegram_bot-chatgpt_telegram_bot:latest
- Deleted: sha256:9038c3ade86386fb6ac43dd261c6d2fe15d15723690d6f68f714fa53197f595a
- [root@192 /]# docker rmi mongo
- Untagged: mongo:latest
- Untagged: mongo@sha256:d341a86584b96eb665345a8f5b35fba8695ee1d0618fd012ec4696223a3d6c62
- Deleted: sha256:ee3b4d1239f12b094c4936dd08a2fbc227300beaf784c46c509e2f1ac5e6d879
- Deleted: sha256:2c22df18633d7c9b5d6ef4b8539586cf496f3adcdb812d4d4376c34fec1c3388
- Deleted: sha256:d2dfd7c53524f72dc4becde40b429a39c9ab942818551818a3ed1543eab19afa
- Deleted: sha256:de7a060374bd4266412939d61dfd672f3660c7cd7609b6c95b33ebba886e620e
- Deleted: sha256:37f49319f9fd1f226e9a8842ab330a6cadf0bbad10a3bea2fd8d96a808d77786
- Deleted: sha256:875c46da359d0601e51fc833a9fb760de6394bca8a4cd91a1274e157efb10791
- Deleted: sha256:fb9a3162c8e724a381642810d948c7684b8678d60df14c5627e68047543f101a
- Deleted: sha256:a51069dd408da3640c8450c88e7c0e887c9f290f4a629cf56c922f4c0dc53e89
- Deleted: sha256:a26e6c0a2d6c1ac98aa99c82760d7ca4f2931da7d9fc3062464487a4e420e6bd
- Deleted: sha256:256d88da41857db513b95b50ba9a9b28491b58c954e25477d5dad8abb465430b
- [root@192 /]# docker rmi mongo-express
- Untagged: mongo-express:latest
- Untagged: mongo-express@sha256:7e4535ac4ed016f495c231833912e27c5e33e4c4fb29a51623db53f52d167e5a
- Deleted: sha256:a776ee465303a59cf7ccc60c4f78c15c3adffce9b09a66a6ae22fb6ad65e2363
- Deleted: sha256:bc6748393bd7bb61eb340ad9074df79806e416621cc21e500a58009e929473fb
- Deleted: sha256:e29995002ae28e12b5650df3800f3c90baaf2f984649daff79d5c125ab6b84d5
- Deleted: sha256:18b7d27b3b6be8b0203aa65e9e60ce7b4f09ec16e3c5d2c669cbcd1de5861e3e
- Deleted: sha256:50f0968a87ba50bac8c7654e3eff200c4aebe6973135b3f90ada663309f705ec
- Deleted: sha256:71463e0403bfe430cba6b4696bdc6a2bcfcf6f1a519fe0eab300cd36605ca95c
- Deleted: sha256:36b50b131297b8860da51b2d2b24bb4c08dfbdf2789b08e3cc0f187c98637a19
4.查看清理的效果
- [root@192 /]# df -h
- 文件系统 容量 已用 可用 已用% 挂载点
- devtmpfs 1.8G 0 1.8G 0% /dev
- tmpfs 1.8G 0 1.8G 0% /dev/shm
- tmpfs 1.8G 8.8M 1.8G 1% /run
- tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
- /dev/mapper/centos-root 25G 9.7G 16G 39% /
- /dev/mmcblk0p2 1014M 144M 871M 15% /boot
- /dev/mmcblk0p1 200M 12M 189M 6% /boot/efi
- overlay 25G 9.7G 16G 39% /var/lib/docker/overlay2/1b8f5c2acbbdf3ab255a5c79c0589c6d937dc476ff1982656dfb237012ca7a3c/merged
- tmpfs 364M 0 364M 0% /run/user/0
可见一下子就腾出了16G的空间
5.进一步清理(使用 Docker 的垃圾回收功能来清理废弃的镜像和容器)
- [root@192 /]# docker system prune -a --volumes
- WARNING! This will remove:
- - all stopped containers
- - all networks not used by at least one container
- - all volumes not used by at least one container
- - all images without at least one container associated to them
- - all build cache
-
- Are you sure you want to continue? [y/N] y
- Deleted Volumes:
- 0480271113e73cb36fe85a787a31f0735db23a6eacd3a353b4a00e06751d199b
- dfb0c22653fb0be599d3dbfa484af12a224593b0ab536f19131aa0795b0891c0
-
- Deleted Images:
- untagged: piaoyizy/openwrt-x86:latest
- untagged: piaoyizy/openwrt-x86@sha256:eee0d2d67167f8927863906fcf6c8efc5ffae806ed56e334b634573b9fa40b73
- deleted: sha256:9bd6fedfe85a9de7a8c19721706d41c155d7d4cdd09e78576bd71b9bcacc8c58
- deleted: sha256:d954d873faab418a3193890202fb2ce289d7d048c048504313fdca0acf72ea7b
- untagged: fluential/ant-media-server:latest
- untagged: fluential/ant-media-server@sha256:c1234782cdbdb44d72d0e77897397fd12dee2ee030cb184a7fb88ce7bcef87db
- deleted: sha256:b5075969a7c06e281ae69b5f595b363e499bb0118c7730128b1e0cc4c072c11a
- deleted: sha256:9543ef1665d9177c29bd6c0b93553efc6f40cd3f10751cf3f672ecc9413a4c2e
- deleted: sha256:db682316bc2e53a1d795626fad6dcef0584f2ca7d5801b6abf89131fbc9edefe
- deleted: sha256:fd43ef285b52ca87800fd2d021e05a3587fc7e0ea843d73d3e0a9e86094f5bc5
- deleted: sha256:2e679ff6214ca6f0705826d1b1704fab0f425395026d7f4d7667347628323a8e
- deleted: sha256:79fff99f20dcbfcb7ba63073d1c8f60b8224257628064af867ec7b5cfa58e957
- deleted: sha256:030309cad0ba82b098939419dcb5e0a95c77d2427d99c44a690ecab59f80a487
- untagged: n3d1117/chatgpt-telegram-bot:latest
- untagged: n3d1117/chatgpt-telegram-bot@sha256:c14938ff38823fa6da2950ffb5f2bca42b1a760801cdbae7c6e3b63ac9fab947
- deleted: sha256:9ccef919d8a7a0f48d6c783bc79a1da7b2cba5049da695949d8efd62f40d3597
- deleted: sha256:df475a276382f9912a02528e45c565e5906dc4534fc5457f023a875364f245fe
- deleted: sha256:2604e2ad28befd019d3d5df8832528d42434c2c95151ff3fe78b1aa096c00385
- deleted: sha256:93dc9b5e30f0d20b6d179d754452d6bd4745a7cc16d5082cbc0e01f74dee3202
- deleted: sha256:d1abf0a112cadb9c04240fc44939fc8533b0e3137a3981c4036866d264267f9c
- deleted: sha256:01b526302eaca0448ce20b947211b0584af57127c002b5d848a6168b0d5157ec
- deleted: sha256:4914f9e83d53d9ca126ac18fbdcbfe2fb3ae880834a2c25960c47c3c057763a7
- deleted: sha256:7505a1413a118095f0d2797bf7edff05c1de28890dfaa472d6b56a69343e9a69
- deleted: sha256:41c54f2f242106529f86fe26e248faa67b193a0710ff832ed4a0d63e0a9c0ace
- deleted: sha256:78a822fe2a2d2c84f3de4a403188c45f623017d6a4521d23047c9fbb0801794c
-
- Total reclaimed space: 2.179GB
6.最终清理效果
- [root@192 /]# df -h
- 文件系统 容量 已用 可用 已用% 挂载点
- devtmpfs 1.8G 0 1.8G 0% /dev
- tmpfs 1.8G 0 1.8G 0% /dev/shm
- tmpfs 1.8G 8.8M 1.8G 1% /run
- tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
- /dev/mapper/centos-root 25G 6.3G 19G 26% /
- /dev/mmcblk0p2 1014M 144M 871M 15% /boot
- /dev/mmcblk0p1 200M 12M 189M 6% /boot/efi
- overlay 25G 6.3G 19G 26% /var/lib/docker/overlay2/1b8f5c2acbbdf3ab255a5c79c0589c6d937dc476ff1982656dfb237012ca7a3c/merged
- tmpfs 364M 0 364M 0% /run/user/0
可见总共腾出了19G的空间。其中16G是手动删除以下指令能看到的镜像和容器得到的
- docker ps -a
- docker images
剩下的3G是使用 Docker 的垃圾回收功能来清理废弃的镜像和容器得到的
docker system prune -a --volumes
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。