{"id":1233,"date":"2023-04-17T16:49:53","date_gmt":"2023-04-17T08:49:53","guid":{"rendered":"https:\/\/www.linuxdevops.cn\/?p=1233"},"modified":"2023-04-17T16:49:53","modified_gmt":"2023-04-17T08:49:53","slug":"docker-space-cleaning-how-to-free-up-disk-space-occupied","status":"publish","type":"post","link":"https:\/\/www.linuxdevops.cn\/2023\/04\/docker-space-cleaning-how-to-free-up-disk-space-occupied\/","title":{"rendered":"Docker\u7a7a\u95f4\u6e05\u7406\uff1a\u5982\u4f55\u91ca\u653eDocker\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\uff1f"},"content":{"rendered":"
Docker\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5bb9\u5668\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u642d\u5efa\u73af\u5883\u3001\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u548c\u670d\u52a1\u3002\u4f46\u662f\uff0cDocker\u5360\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u4f1a\u4e0d\u65ad\u589e\u957f\uff0c\u5927\u91cf\u65e0\u7528\u7684\u5bb9\u5668\u3001\u955c\u50cf\u3001\u6570\u636e\u5377\u548c\u7f51\u7edc\u7b49\u4f1a\u5bfc\u81f4\u78c1\u76d8\u7a7a\u95f4\u4e0d\u8db3\uff0c\u5f71\u54cd\u7cfb\u7edf\u6027\u80fd\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u671f\u6e05\u7406Docker\u7a7a\u95f4\uff0c\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n
\u672c\u6587\u5c06\u4ecb\u7ecd\u4e00\u4e9b\u5e38\u7528\u7684Docker\u7a7a\u95f4\u6e05\u7406\u65b9\u6cd5\uff0c\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7ba1\u7406Docker\u7a7a\u95f4\u3002<\/p>\n
\u4f7f\u7528\u547d\u4ee4 \u4f7f\u7528\u547d\u4ee4 \u4f7f\u7528\u547d\u4ee4 \u4f7f\u7528\u547d\u4ee4 \u4f7f\u7528\u547d\u4ee4 \u4f7f\u7528\u547d\u4ee4 Docker\u65e5\u5fd7\u4f1a\u5360\u7528\u5927\u91cf\u7a7a\u95f4\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4 \u603b\u7ed3<\/p>\n Docker\u7a7a\u95f4\u6e05\u7406\u662f\u4e00\u9879\u5fc5\u8981\u7684\u4efb\u52a1\uff0c\u53ef\u4ee5\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0c\u63d0\u9ad8\u7cfb\u7edf\u6027\u80fd\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u4e00\u4e9b\u5e38\u7528\u7684Docker\u7a7a\u95f4\u6e05\u7406\u65b9\u6cd5\uff0c\u5305\u62ec\u6e05\u7406\u65e0\u7528\u7684\u5bb9\u5668\u3001\u955c\u50cf\u3001\u6570\u636e\u5377\u548c\u7f51\u7edc\u7b49\uff0c\u6e05\u7406Docker\u955c\u50cf\u7f13\u5b58\u548c\u65e5\u5fd7\u7b49\u3002\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u9009\u62e9\u9002\u5f53\u7684\u65b9\u6cd5\u8fdb\u884c\u6e05\u7406\uff0c\u4fdd\u6301Docker\u7a7a\u95f4\u7684\u6574\u6d01\u548c\u9ad8\u6548\u3002<\/p>\n","protected":false},"excerpt":{"rendered":" Docker\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5bb9\u5668\u5316\u6280\u672f\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u5feb\u901f\u642d\u5efa\u73af\u5883\u3001\u7ba1\u7406\u5e94\u7528\u7a0b\u5e8f\u548c\u670d\u52a1\u3002\u4f46\u662f\uff0cDocker\u5360\u7528\u7684<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,18],"tags":[126],"yoast_head":"\ndocker ps -a<\/code>\u5217\u51fa\u6240\u6709\u5bb9\u5668\uff0c\u627e\u51fa\u4e0d\u518d\u9700\u8981\u7684\u5bb9\u5668\uff0c\u4f7f\u7528\u547d\u4ee4
docker rm <container_id><\/code>\u5220\u9664\u5b83\u4eec\u3002\u5728\u5220\u9664\u5bb9\u5668\u4e4b\u524d\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4
docker stop <container_id><\/code>\u5148\u505c\u6b62\u5bb9\u5668\u3002<\/p>\n
\n
docker images<\/code>\u5217\u51fa\u6240\u6709\u955c\u50cf\uff0c\u627e\u51fa\u4e0d\u518d\u9700\u8981\u7684\u955c\u50cf\uff0c\u4f7f\u7528\u547d\u4ee4
docker rmi <image_id><\/code>\u5220\u9664\u5b83\u4eec\u3002\u5728\u5220\u9664\u955c\u50cf\u4e4b\u524d\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4
docker stop <container_id><\/code>\u5148\u505c\u6b62\u5bb9\u5668\u3002<\/p>\n
\n
docker volume ls<\/code>\u5217\u51fa\u6240\u6709\u6570\u636e\u5377\uff0c\u627e\u51fa\u4e0d\u518d\u9700\u8981\u7684\u6570\u636e\u5377\uff0c\u4f7f\u7528\u547d\u4ee4
docker volume rm <volume_name><\/code>\u5220\u9664\u5b83\u4eec\u3002\u5728\u5220\u9664\u6570\u636e\u5377\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5220\u9664\u4f7f\u7528\u8be5\u6570\u636e\u5377\u7684\u5bb9\u5668\u3002<\/p>\n
\n
docker network ls<\/code>\u5217\u51fa\u6240\u6709\u7f51\u7edc\uff0c\u627e\u51fa\u4e0d\u518d\u9700\u8981\u7684\u7f51\u7edc\uff0c\u4f7f\u7528\u547d\u4ee4
docker network rm <network_name><\/code>\u5220\u9664\u5b83\u4eec\u3002\u5728\u5220\u9664\u7f51\u7edc\u4e4b\u524d\uff0c\u9700\u8981\u5148\u5220\u9664\u4f7f\u7528\u8be5\u7f51\u7edc\u7684\u5bb9\u5668\u3002<\/p>\n
\n
docker system prune<\/code>\u53ef\u4ee5\u6e05\u7406\u65e0\u7528\u7684\u5bb9\u5668\u3001\u955c\u50cf\u3001\u6570\u636e\u5377\u548c\u7f51\u7edc\u7b49\u6240\u6709\u7f13\u5b58\u3002\u8fd9\u662f\u4e00\u79cd\u6bd4\u8f83\u65b9\u4fbf\u7684\u65b9\u6cd5\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u4e0d\u8981\u8bef\u5220\u91cd\u8981\u7684\u5185\u5bb9\u3002<\/p>\n
\n
docker image prune -a<\/code>\u53ef\u4ee5\u6e05\u7406\u6240\u6709\u672a\u88ab\u4f7f\u7528\u7684\u955c\u50cf\u7f13\u5b58\u3002\u8fd9\u662f\u4e00\u79cd\u6bd4\u8f83\u5f7b\u5e95\u7684\u6e05\u7406\u65b9\u6cd5\uff0c\u4f46\u9700\u8981\u6ce8\u610f\u4e0d\u8981\u8bef\u5220\u91cd\u8981\u7684\u955c\u50cf\u3002<\/p>\n
\n
docker logs --tail 50 <container_id><\/code>\u6765\u67e5\u770b\u6700\u8fd150\u884c\u7684\u65e5\u5fd7\u3002\u5982\u679c\u9700\u8981\u6e05\u7406\u5168\u90e8\u65e5\u5fd7\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4
truncate -s 0 \/var\/lib\/docker\/containers\/*\/*\/*.log<\/code>\u6765\u6e05\u7a7a\u6240\u6709\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n