当前位置:   article > 正文

/dev/mapper/centos-root或/var/lib/docker/overlay2 占满的解决方法_/dev/mapper/system-root空间满了

/dev/mapper/system-root空间满了

实际清理过程如下(省略了不必要的部分)

1.查找占用过大的部分

  1. df -h
  2. 文件系统 容量 已用 可用 已用% 挂载点
  3. devtmpfs 1.8G 0 1.8G 0% /dev
  4. tmpfs 1.8G 0 1.8G 0% /dev/shm
  5. tmpfs 1.8G 8.8M 1.8G 1% /run
  6. tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
  7. /dev/mapper/centos-root 25G 25G 628M 98% /
  8. /dev/mmcblk0p2 1014M 144M 871M 15% /boot
  9. /dev/mmcblk0p1 200M 12M 189M 6% /boot/efi
  10. overlay 25G 25G 628M 98% /var/lib/docker/overlay2/1b8f5c2acbbdf3ab255a5c79c0589c6d937dc476ff1982656dfb237012ca7a3c/merged
  11. tmpfs 364M 0 364M 0% /run/user/0
  1. [root@192 /]# du -h --max-depth=1 /var | sort -hr
  2. 19G /var/lib
  3. 19G /var
  4. 236M /var/cache
  5. 118M /var/log
  1. [root@192 /]# du -h --max-depth=1 /var/lib | sort -hr
  2. 19G /var/lib/docker
  3. 19G /var/lib
  4. 70M /var/lib/rpm
  1. [root@192 /]# du -h --max-depth=1 /var/lib/docker | sort -hr
  2. 19G /var/lib/docker/overlay2
  3. 19G /var/lib/docker
  4. 206M /var/lib/docker/volumes
  1. [root@192 /]# du -h --max-depth=1 /var/lib/docker/overlay2 | sort -hr
  2. 19G /var/lib/docker/overlay2
  3. 13G /var/lib/docker/overlay2/e9b9d91569738f353952e1bac8e125ebbc1ff4f2787fe6d038c2f6d65092a768
  4. 923M /var/lib/docker/overlay2/6b1db6c265c347fe95bf06715e294c3b6db53c44aa7eea02e1a713c2fa4420a5
  5. 856M /var/lib/docker/overlay2/2025b2c26a61e95fabab2214c5631826582b410602d59033b305f33eb6b6a201
  6. 821M /var/lib/docker/overlay2/k999kyt8bwlgvfqaelbvv7xlt
  7. 629M /var/lib/docker/overlay2/ef842b6641c59b9036643ade3716bef622860911ba08347beee655eff8e15e45

2.以上可知是docker的镜像和容器的问题,查看是否属实

  1. [root@192 /]# docker images
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. zhayujie/chatgpt-on-wechat latest 0a986254a516 2 weeks ago 1.47GB
  4. chatgpt-telegram-bot-chatgpt-telegram-bot latest 877cecd7d0d0 2 weeks ago 232MB
  5. chatgpt-telegram-bot latest 2889f1e1be10 2 weeks ago 232MB
  6. chatgpt_telegram_bot-chatgpt_telegram_bot latest 9038c3ade863 2 weeks ago 1.03GB
  7. mongo latest ee3b4d1239f1 3 weeks ago 748MB
  8. mongo-express latest a776ee465303 3 weeks ago 247MB
  9. piaoyizy/openwrt-x86 latest 9bd6fedfe85a 2 months ago 265MB
  10. n3d1117/chatgpt-telegram-bot latest 9ccef919d8a7 2 months ago 234MB
  11. registry.cn-shanghai.aliyuncs.com/suling/openwrt x86_64 3d9db27509a6 6 months ago 223MB
  12. fluential/ant-media-server latest b5075969a7c0 2 years ago 1.47GB
  13. [root@192 /]# docker ps -a
  14. CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  15. 19a9f82fefd9 zhayujie/chatgpt-on-wechat "/entrypoint.sh" 2 weeks ago Exited (137) 7 days ago chatgpt-on-wechat
  16. 31f1a2a4a9ea chatgpt-telegram-bot-chatgpt-telegram-bot "python bot/main.py" 2 weeks ago Up 7 days chatgpt-telegram-bot-chatgpt-telegram-bot-1
  17. 31424d502836 chatgpt_telegram_bot-chatgpt_telegram_bot "python3 bot/bot.py" 2 weeks ago Up 7 days chatgpt_telegram_bot
  18. 83884b413e47 mongo-express:latest "/sbin/tini -- /dock…" 2 weeks ago Up 7 days 127.0.0.1:8081->8081/tcp mongo-express
  19. bdb0e92635a9 mongo:latest "docker-entrypoint.s…" 2 weeks ago Up 7 days 127.0.0.1:27017->27017/tcp mongo
  20. ba83c9a756e0 registry.cn-shanghai.aliyuncs.com/suling/openwrt:x86_64 "/sbin/init" 7 weeks ago Up 7 days openwrt

3.确实有很多无用的镜像和容器,开始清理

  1. [root@192 /]# docker rm 19a9f82fefd9
  2. 19a9f82fefd9
  3. [root@192 /]# docker rm 31f1a2a4a9ea
  4. 31f1a2a4a9ea
  5. [root@192 /]# docker rm 31424d502836
  6. 31424d502836
  7. [root@192 /]# docker rm 83884b413e47
  8. 83884b413e47
  9. [root@192 /]# docker rm bdb0e92635a9
  10. bdb0e92635a9
  11. [root@192 /]# docker rmi zhayujie/chatgpt-on-wechat
  12. Untagged: zhayujie/chatgpt-on-wechat:latest
  13. Untagged: zhayujie/chatgpt-on-wechat@sha256:0a6b9797060c30fda65461830ac61ad7381817724dfb1aaf76f6cad3fdc5b4db
  14. Deleted: sha256:0a986254a51643727fe4e307711d91f1312017211ded80d29a774a30c2523602
  15. Deleted: sha256:92b898842bc894baaf4c9e34875556acca80774f60125fb3e0057aa711d801ab
  16. Deleted: sha256:928c604cf5392e89e2df5b23d43a946fbc734905b83eaad9d0ab9801a6c60292
  17. Deleted: sha256:f55f989a1c7a34bb0fb426063c29d5ba9dd8bd1800049cb5c1d861f05e5b63b2
  18. Deleted: sha256:2304920254d30fa44ea593be377c7da2d6306fd1c0a243d7ed7862f3fa39c188
  19. Deleted: sha256:c47468a68539df36059733e5b5f1ec2c2234ba0513e3f376fcfa1af6a3f7ab32
  20. Deleted: sha256:ec80711e62e340b2f946cf27ca37cb1ef80e80c0fe7a935b839280eb48877be5
  21. Deleted: sha256:4cfe60da3ca70228f754c18026c559b8ea170a49cfcb469b2511f08ce464f9ae
  22. Deleted: sha256:ff26b446031a39486cbe2b65c25dca7457606b9953875261cb73f67372580648
  23. Deleted: sha256:3a9ca5d5b0fd0ccb20b8e5f8d4ee2c644a1da536f6b75f1efd600617baeabac1
  24. Deleted: sha256:96c394b48a395f533a0f1770d7e23e8405a9aa2375efa0e75c3401ee3ad55ea9
  25. Deleted: sha256:633f5bf471f7595b236a21e62dc60beef321db45916363a02ad5af02d794d497
  26. [root@192 /]# docker rmi chatgpt-telegram-bot-chatgpt-telegram-bot
  27. Untagged: chatgpt-telegram-bot-chatgpt-telegram-bot:latest
  28. Deleted: sha256:877cecd7d0d0009433fc659f23091e947c3439684874a4ed2eb732c3124114de
  29. [root@192 /]# docker rmi chatgpt-telegram-bot
  30. Untagged: chatgpt-telegram-bot:latest
  31. Deleted: sha256:2889f1e1be10d5e72169ee72cfed66c03bc6c09ad1d0410f53a6a5f31b8c33c9
  32. [root@192 /]# docker rmi chatgpt_telegram_bot-chatgpt_telegram_bot
  33. Untagged: chatgpt_telegram_bot-chatgpt_telegram_bot:latest
  34. Deleted: sha256:9038c3ade86386fb6ac43dd261c6d2fe15d15723690d6f68f714fa53197f595a
  35. [root@192 /]# docker rmi mongo
  36. Untagged: mongo:latest
  37. Untagged: mongo@sha256:d341a86584b96eb665345a8f5b35fba8695ee1d0618fd012ec4696223a3d6c62
  38. Deleted: sha256:ee3b4d1239f12b094c4936dd08a2fbc227300beaf784c46c509e2f1ac5e6d879
  39. Deleted: sha256:2c22df18633d7c9b5d6ef4b8539586cf496f3adcdb812d4d4376c34fec1c3388
  40. Deleted: sha256:d2dfd7c53524f72dc4becde40b429a39c9ab942818551818a3ed1543eab19afa
  41. Deleted: sha256:de7a060374bd4266412939d61dfd672f3660c7cd7609b6c95b33ebba886e620e
  42. Deleted: sha256:37f49319f9fd1f226e9a8842ab330a6cadf0bbad10a3bea2fd8d96a808d77786
  43. Deleted: sha256:875c46da359d0601e51fc833a9fb760de6394bca8a4cd91a1274e157efb10791
  44. Deleted: sha256:fb9a3162c8e724a381642810d948c7684b8678d60df14c5627e68047543f101a
  45. Deleted: sha256:a51069dd408da3640c8450c88e7c0e887c9f290f4a629cf56c922f4c0dc53e89
  46. Deleted: sha256:a26e6c0a2d6c1ac98aa99c82760d7ca4f2931da7d9fc3062464487a4e420e6bd
  47. Deleted: sha256:256d88da41857db513b95b50ba9a9b28491b58c954e25477d5dad8abb465430b
  48. [root@192 /]# docker rmi mongo-express
  49. Untagged: mongo-express:latest
  50. Untagged: mongo-express@sha256:7e4535ac4ed016f495c231833912e27c5e33e4c4fb29a51623db53f52d167e5a
  51. Deleted: sha256:a776ee465303a59cf7ccc60c4f78c15c3adffce9b09a66a6ae22fb6ad65e2363
  52. Deleted: sha256:bc6748393bd7bb61eb340ad9074df79806e416621cc21e500a58009e929473fb
  53. Deleted: sha256:e29995002ae28e12b5650df3800f3c90baaf2f984649daff79d5c125ab6b84d5
  54. Deleted: sha256:18b7d27b3b6be8b0203aa65e9e60ce7b4f09ec16e3c5d2c669cbcd1de5861e3e
  55. Deleted: sha256:50f0968a87ba50bac8c7654e3eff200c4aebe6973135b3f90ada663309f705ec
  56. Deleted: sha256:71463e0403bfe430cba6b4696bdc6a2bcfcf6f1a519fe0eab300cd36605ca95c
  57. Deleted: sha256:36b50b131297b8860da51b2d2b24bb4c08dfbdf2789b08e3cc0f187c98637a19

4.查看清理的效果

  1. [root@192 /]# df -h
  2. 文件系统 容量 已用 可用 已用% 挂载点
  3. devtmpfs 1.8G 0 1.8G 0% /dev
  4. tmpfs 1.8G 0 1.8G 0% /dev/shm
  5. tmpfs 1.8G 8.8M 1.8G 1% /run
  6. tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
  7. /dev/mapper/centos-root 25G 9.7G 16G 39% /
  8. /dev/mmcblk0p2 1014M 144M 871M 15% /boot
  9. /dev/mmcblk0p1 200M 12M 189M 6% /boot/efi
  10. overlay 25G 9.7G 16G 39% /var/lib/docker/overlay2/1b8f5c2acbbdf3ab255a5c79c0589c6d937dc476ff1982656dfb237012ca7a3c/merged
  11. tmpfs 364M 0 364M 0% /run/user/0

可见一下子就腾出了16G的空间

5.进一步清理(使用 Docker 的垃圾回收功能来清理废弃的镜像和容器)

  1. [root@192 /]# docker system prune -a --volumes
  2. WARNING! This will remove:
  3. - all stopped containers
  4. - all networks not used by at least one container
  5. - all volumes not used by at least one container
  6. - all images without at least one container associated to them
  7. - all build cache
  8. Are you sure you want to continue? [y/N] y
  9. Deleted Volumes:
  10. 0480271113e73cb36fe85a787a31f0735db23a6eacd3a353b4a00e06751d199b
  11. dfb0c22653fb0be599d3dbfa484af12a224593b0ab536f19131aa0795b0891c0
  12. Deleted Images:
  13. untagged: piaoyizy/openwrt-x86:latest
  14. untagged: piaoyizy/openwrt-x86@sha256:eee0d2d67167f8927863906fcf6c8efc5ffae806ed56e334b634573b9fa40b73
  15. deleted: sha256:9bd6fedfe85a9de7a8c19721706d41c155d7d4cdd09e78576bd71b9bcacc8c58
  16. deleted: sha256:d954d873faab418a3193890202fb2ce289d7d048c048504313fdca0acf72ea7b
  17. untagged: fluential/ant-media-server:latest
  18. untagged: fluential/ant-media-server@sha256:c1234782cdbdb44d72d0e77897397fd12dee2ee030cb184a7fb88ce7bcef87db
  19. deleted: sha256:b5075969a7c06e281ae69b5f595b363e499bb0118c7730128b1e0cc4c072c11a
  20. deleted: sha256:9543ef1665d9177c29bd6c0b93553efc6f40cd3f10751cf3f672ecc9413a4c2e
  21. deleted: sha256:db682316bc2e53a1d795626fad6dcef0584f2ca7d5801b6abf89131fbc9edefe
  22. deleted: sha256:fd43ef285b52ca87800fd2d021e05a3587fc7e0ea843d73d3e0a9e86094f5bc5
  23. deleted: sha256:2e679ff6214ca6f0705826d1b1704fab0f425395026d7f4d7667347628323a8e
  24. deleted: sha256:79fff99f20dcbfcb7ba63073d1c8f60b8224257628064af867ec7b5cfa58e957
  25. deleted: sha256:030309cad0ba82b098939419dcb5e0a95c77d2427d99c44a690ecab59f80a487
  26. untagged: n3d1117/chatgpt-telegram-bot:latest
  27. untagged: n3d1117/chatgpt-telegram-bot@sha256:c14938ff38823fa6da2950ffb5f2bca42b1a760801cdbae7c6e3b63ac9fab947
  28. deleted: sha256:9ccef919d8a7a0f48d6c783bc79a1da7b2cba5049da695949d8efd62f40d3597
  29. deleted: sha256:df475a276382f9912a02528e45c565e5906dc4534fc5457f023a875364f245fe
  30. deleted: sha256:2604e2ad28befd019d3d5df8832528d42434c2c95151ff3fe78b1aa096c00385
  31. deleted: sha256:93dc9b5e30f0d20b6d179d754452d6bd4745a7cc16d5082cbc0e01f74dee3202
  32. deleted: sha256:d1abf0a112cadb9c04240fc44939fc8533b0e3137a3981c4036866d264267f9c
  33. deleted: sha256:01b526302eaca0448ce20b947211b0584af57127c002b5d848a6168b0d5157ec
  34. deleted: sha256:4914f9e83d53d9ca126ac18fbdcbfe2fb3ae880834a2c25960c47c3c057763a7
  35. deleted: sha256:7505a1413a118095f0d2797bf7edff05c1de28890dfaa472d6b56a69343e9a69
  36. deleted: sha256:41c54f2f242106529f86fe26e248faa67b193a0710ff832ed4a0d63e0a9c0ace
  37. deleted: sha256:78a822fe2a2d2c84f3de4a403188c45f623017d6a4521d23047c9fbb0801794c
  38. Total reclaimed space: 2.179GB

6.最终清理效果

  1. [root@192 /]# df -h
  2. 文件系统 容量 已用 可用 已用% 挂载点
  3. devtmpfs 1.8G 0 1.8G 0% /dev
  4. tmpfs 1.8G 0 1.8G 0% /dev/shm
  5. tmpfs 1.8G 8.8M 1.8G 1% /run
  6. tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
  7. /dev/mapper/centos-root 25G 6.3G 19G 26% /
  8. /dev/mmcblk0p2 1014M 144M 871M 15% /boot
  9. /dev/mmcblk0p1 200M 12M 189M 6% /boot/efi
  10. overlay 25G 6.3G 19G 26% /var/lib/docker/overlay2/1b8f5c2acbbdf3ab255a5c79c0589c6d937dc476ff1982656dfb237012ca7a3c/merged
  11. tmpfs 364M 0 364M 0% /run/user/0

可见总共腾出了19G的空间。其中16G是手动删除以下指令能看到的镜像和容器得到的

  1. docker ps -a
  2. docker images

剩下的3G是使用 Docker 的垃圾回收功能来清理废弃的镜像和容器得到的

docker system prune -a --volumes

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/166435
推荐阅读
相关标签
  

闽ICP备14008679号