{"id":108064,"date":"2026-09-20T21:49:42","date_gmt":"2026-09-20T13:49:42","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/108064.html"},"modified":"2026-09-20T21:49:42","modified_gmt":"2026-09-20T13:49:42","slug":"%e3%80%90docker%e3%80%91%e5%ae%b9%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/108064.html","title":{"rendered":"\u3010Docker\u3011\u5bb9\u5668"},"content":{"rendered":"<p>&#x1f308;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u79e6jh__https:\/\/blog.csdn.net\/qinjh_?spm&#061;1010.2135.3001.5343 &#x1f525;\u00a0\u7cfb\u5217\u4e13\u680f&#xff1a;Docker_\u79e6jh_\u7684\u535a\u5ba2-CSDN\u535a\u5ba2<\/p>\n<p>\u00a0\u00a0<img decoding=\"async\" alt=\"9efbcbc3d25747719da38c01b3fa9b4f.gif\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134923-6aafe4636b9a8.gif\" \/>\u200b\u200b\u200b\u200b\u200b<\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"Docker%20Container%EF%BC%88%E5%AE%B9%E5%99%A8%EF%BC%89-toc\" style=\"margin-left:0px\">Docker Container&#xff08;\u5bb9\u5668&#xff09;<\/p>\n<p id=\"%E4%BB%80%E4%B9%88%E6%98%AF%E5%AE%B9%E5%99%A8%EF%BC%9F-toc\" style=\"margin-left:40px\">\u4ec0\u4e48\u662f\u5bb9\u5668&#xff1f;<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E7%94%9F%E6%B4%BB%E6%A1%88%E4%BE%8B-toc\" style=\"margin-left:40px\">\u5bb9\u5668\u751f\u6d3b\u6848\u4f8b<\/p>\n<p id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E5%AE%B9%E5%99%A8%EF%BC%9F-toc\" style=\"margin-left:40px\">\u4e3a\u4ec0\u4e48\u9700\u8981\u5bb9\u5668&#xff1f;<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F-toc\" style=\"margin-left:40px\">\u5bb9\u5668\u7684\u751f\u547d\u5468\u671f<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%20OOM-toc\" style=\"margin-left:80px\">\u5bb9\u5668 OOM<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E5%BC%82%E5%B8%B8%E9%80%80%E5%87%BA-toc\" style=\"margin-left:80px\">\u5bb9\u5668\u5f02\u5e38\u9000\u51fa<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E6%9A%82%E5%81%9C-toc\" style=\"margin-left:80px\">\u5bb9\u5668\u6682\u505c<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E5%91%BD%E4%BB%A4%E6%B8%85%E5%8D%95-toc\" style=\"margin-left:40px\">\u5bb9\u5668\u547d\u4ee4\u6e05\u5355<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3-toc\" style=\"margin-left:40px\">\u5bb9\u5668\u547d\u4ee4\u8be6\u89e3<\/p>\n<p id=\"docker%20create-toc\" style=\"margin-left:80px\">docker create<\/p>\n<p id=\"docker%20run-toc\" style=\"margin-left:80px\">docker run<\/p>\n<p id=\"docker%20ps-toc\" style=\"margin-left:80px\">docker ps<\/p>\n<p id=\"docker%20logs-toc\" style=\"margin-left:80px\">docker logs<\/p>\n<p id=\"docker%20attach-toc\" style=\"margin-left:80px\">docker attach<\/p>\n<p id=\"docker%20exec-toc\" style=\"margin-left:80px\">docker exec<\/p>\n<p id=\"docker%20start-toc\" style=\"margin-left:80px\">docker start<\/p>\n<p id=\"docker%20stop-toc\" style=\"margin-left:80px\">docker stop<\/p>\n<p id=\"docker%20restart-toc\" style=\"margin-left:80px\">docker restart<\/p>\n<p id=\"docker%20kill-toc\" style=\"margin-left:80px\">docker kill<\/p>\n<p id=\"docker%20top-toc\" style=\"margin-left:80px\">docker top<\/p>\n<p id=\"docker%20stats-toc\" style=\"margin-left:80px\">docker stats<\/p>\n<p id=\"docker%20container%20inspect-toc\" style=\"margin-left:80px\">docker container inspect<\/p>\n<p id=\"docker%20port-toc\" style=\"margin-left:80px\">docker port<\/p>\n<p id=\"docker%20cp-toc\" style=\"margin-left:80px\">docker cp<\/p>\n<p id=\"docker%20diff-toc\" style=\"margin-left:80px\">docker diff<\/p>\n<p id=\"docker%20commit-toc\" style=\"margin-left:80px\">docker commit<\/p>\n<p id=\"docker%20pause-toc\" style=\"margin-left:80px\">docker pause<\/p>\n<p id=\"docker%20unpause-toc\" style=\"margin-left:80px\">docker unpause<\/p>\n<p id=\"docker%20rm-toc\" style=\"margin-left:80px\">docker rm<\/p>\n<p id=\"docker%20export-toc\" style=\"margin-left:80px\">docker export<\/p>\n<p id=\"docker%20wait-toc\" style=\"margin-left:80px\">docker wait<\/p>\n<p id=\"docker%20rename-toc\" style=\"margin-left:80px\">docker rename<\/p>\n<p id=\"docker%20container%20prune-toc\" style=\"margin-left:80px\">docker container prune<\/p>\n<p id=\"docker%20update-toc\" style=\"margin-left:80px\">docker update<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E6%93%8D%E4%BD%9C%E6%A1%88%E4%BE%8B-toc\" style=\"margin-left:40px\">\u5bb9\u5668\u64cd\u4f5c\u6848\u4f8b<\/p>\n<p id=\"%E5%AE%B9%E5%99%A8%E4%BA%A4%E4%BA%92%E6%A8%A1%E5%BC%8F-toc\" style=\"margin-left:80px\">\u5bb9\u5668\u4ea4\u4e92\u6a21\u5f0f<\/p>\n<p id=\"attached%20%E6%A8%A1%E5%BC%8F-toc\" style=\"margin-left:120px\">attached \u6a21\u5f0f<\/p>\n<p id=\"detached%20%E6%A8%A1%E5%BC%8F-toc\" style=\"margin-left:120px\">detached \u6a21\u5f0f<\/p>\n<p id=\"interactive%20%E6%A8%A1%E5%BC%8F-toc\" style=\"margin-left:120px\">interactive \u6a21\u5f0f<\/p>\n<p id=\"%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98-toc\" style=\"margin-left:40px\">\u5e38\u89c1\u95ee\u9898<\/p>\n<p id=\"docker%20create%E3%80%81docker%20start%20%E5%92%8C%20docker%20run%20%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F-toc\" style=\"margin-left:80px\">docker create\u3001docker start \u548c docker run \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/p>\n<p id=\"docker%20import%20%E5%92%8C%20docker%20load%20%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F-toc\" style=\"margin-left:80px\">docker import \u548c docker load \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/p>\n<p id=\"docker%20rm%20%26%20docker%20rmi%20%26%20docker%20prune%20%E7%9A%84%E5%B7%AE%E5%BC%82%EF%BC%9F-toc\" style=\"margin-left:40px\">docker rm &amp; docker rmi &amp; docker prune \u7684\u5dee\u5f02&#xff1f;<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 id=\"%E5%89%8D%E8%A8%80\">\u524d\u8a00<\/h2>\n<p>\u2002\u2002\u2002\u2002&#x1f4ac; hello! \u5404\u4f4d\u94c1\u5b50\u4eec\u5927\u5bb6\u597d\u54c7\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u4eca\u65e5\u66f4\u65b0\u4e86Docker\u76f8\u5173\u5185\u5bb9 \u2002\u2002\u2002\u2002&#x1f389; \u6b22\u8fce\u5927\u5bb6\u5173\u6ce8&#x1f50d;\u70b9\u8d5e&#x1f44d;\u6536\u85cf\u2b50\ufe0f\u7559\u8a00&#x1f4dd;<\/p>\n<h2 id=\"Docker%20Container%EF%BC%88%E5%AE%B9%E5%99%A8%EF%BC%89\">Docker Container&#xff08;\u5bb9\u5668&#xff09;<\/h2>\n<h3 id=\"%E4%BB%80%E4%B9%88%E6%98%AF%E5%AE%B9%E5%99%A8%EF%BC%9F\">\u4ec0\u4e48\u662f\u5bb9\u5668&#xff1f;<\/h3>\n<p>\u901a\u4fd7\u5730\u8bb2&#xff0c;\u5bb9\u5668\u662f\u955c\u50cf\u7684\u8fd0\u884c\u5b9e\u4f53\u3002\u955c\u50cf\u662f\u9759\u6001\u7684\u53ea\u8bfb\u6587\u4ef6&#xff0c;\u800c\u5bb9\u5668\u5e26\u6709\u8fd0\u884c\u65f6\u9700\u8981 \u7684\u53ef\u5199\u6587\u4ef6\u5c42&#xff0c;\u5e76\u4e14\u5bb9\u5668\u4e2d\u7684\u8fdb\u7a0b\u5c5e\u4e8e\u8fd0\u884c\u72b6\u6001\u3002\u5373\u5bb9\u5668\u8fd0\u884c\u7740\u771f\u6b63\u7684\u5e94\u7528\u8fdb\u7a0b\u3002\u5bb9 \u5668\u6709\u521d\u5efa\u3001\u8fd0\u884c\u3001\u505c\u6b62\u3001\u6682\u505c\u548c\u5220\u9664\u4e94\u79cd\u72b6\u6001\u3002<\/p>\n<p>\u867d\u7136\u5bb9\u5668\u7684\u672c\u8d28\u662f\u4e3b\u673a\u4e0a\u8fd0\u884c\u7684\u4e00\u4e2a\u8fdb\u7a0b&#xff0c;\u4f46\u662f\u5bb9\u5668\u6709\u81ea\u5df1\u72ec\u7acb\u7684\u547d\u540d\u7a7a\u95f4\u9694\u79bb\u548c\u8d44 \u6e90\u9650\u5236\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u5728\u5bb9\u5668\u5185\u90e8&#xff0c;\u65e0\u6cd5\u770b\u5230\u4e3b\u673a\u4e0a\u7684\u8fdb\u7a0b\u3001\u73af\u5883\u53d8\u91cf\u3001\u7f51\u7edc\u7b49\u4fe1\u606f&#xff0c; \u8fd9\u662f\u5bb9\u5668\u4e0e\u76f4\u63a5\u8fd0\u884c\u5728\u4e3b\u673a\u4e0a\u8fdb\u7a0b\u7684\u672c\u8d28\u533a\u522b<\/p>\n<p>\u5bb9\u5668\u662f\u57fa\u4e8e\u955c\u50cf\u521b\u5efa\u7684\u53ef\u8fd0\u884c\u5b9e\u4f8b&#xff0c;\u5e76\u4e14\u5355\u72ec\u5b58\u5728&#xff0c;\u4e00\u4e2a\u955c\u50cf\u53ef\u4ee5\u521b\u5efa\u51fa\u591a\u4e2a\u5bb9\u5668\u3002 \u8fd0\u884c\u5bb9\u5668\u5316\u73af\u5883\u65f6&#xff0c;\u5b9e\u9645\u4e0a\u662f\u5728\u5bb9\u5668\u5185\u90e8\u521b\u5efa\u8be5\u6587\u4ef6\u7cfb\u7edf\u7684\u8bfb\u5199\u526f\u672c\u3002 \u8fd9\u5c06\u6dfb\u52a0\u4e00\u4e2a \u5bb9\u5668\u5c42&#xff0c;\u8be5\u5c42\u5141\u8bb8\u4fee\u6539\u955c\u50cf\u7684\u6574\u4e2a\u526f\u672c<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1600\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134923-6aafe463d7851.png\" width=\"2624\" \/><\/p>\n<h3 id=\"%E5%AE%B9%E5%99%A8%E7%94%9F%E6%B4%BB%E6%A1%88%E4%BE%8B\">\u5bb9\u5668\u751f\u6d3b\u6848\u4f8b<\/h3>\n<p>\u955c\u50cf\u4e0e\u5bb9\u5668\u5c31\u76f8\u5f53\u4e8e\u540c\u6837\u662f\u5f00\u53d1\u5546\u63d0\u4f9b\u7684\u6bdb\u576f\u623f&#xff0c;\u4f46\u662f\u4e24\u5bb6\u4eba\u88c5\u4fee\u51fa\u6765\u7684\u5b8c\u5168\u4e0d\u4e00\u6837\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"309\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134927-6aafe467a9646.png\" width=\"875\" \/><\/p>\n<p>\u6216\u8005\u6211\u4eec\u90fd\u5b66\u4e60\u4e86 Java \u6216\u8005 C&#043;&#043;\u4e4b\u7c7b\u7684\u9762\u5411\u5bf9\u8c61\u7684\u8bed\u8a00&#xff0c;\u53ef\u4ee5\u7406\u89e3\u4e3a\u955c\u50cf\u4e3a\u57fa\u7840\u7c7b&#xff0c; \u5bb9\u5668\u662f\u5b9e\u4f8b\u5316\u51fa\u6765\u7684\u4e00\u4e2a\u4e2a\u5bf9\u8c61&#xff0c;\u6ca1\u6709\u7528\u6237\u9700\u8981\u7684\u4e0d\u4e00\u6837&#xff0c;\u91cc\u9762\u7684\u5185\u5bb9\u4e5f\u5c31\u4e0d\u4e00\u6837\u4e86\u3002<\/p>\n<h3 id=\"%E4%B8%BA%E4%BB%80%E4%B9%88%E9%9C%80%E8%A6%81%E5%AE%B9%E5%99%A8%EF%BC%9F\">\u4e3a\u4ec0\u4e48\u9700\u8981\u5bb9\u5668&#xff1f;<\/h3>\n<p>\u955c\u50cf\u662f\u9759\u6001\u7684\u6587\u4ef6&#xff0c;\u5e76\u4e0d\u80fd\u63d0\u4f9b\u670d\u52a1&#xff0c;\u5c31\u50cf\u6211\u62ff\u4e86\u4e2a Linux \u6216\u8005 Windows \u7684\u5149\u76d8\u4e00\u6837&#xff0c; \u53ea\u6709\u5b89\u88c5\u5230\u4e3b\u673a\u91cc\u9762\u8fd0\u884c\u8d77\u6765\u624d\u80fd\u5bf9\u5916\u63d0\u4f9b\u670d\u52a1&#xff0c;\u6211\u4eec\u624d\u80fd\u4f7f\u7528\u3002<\/p>\n<p>\u5bb9\u5668\u5e26\u6765\u54ea\u4e9b\u6536\u76ca\u5462&#xff0c;\u53c2\u8003\u6211\u4eec\u4e4b\u524d\u8bb2\u89e3\u7684\u4e3a\u4ec0\u4e48\u8981\u865a\u62df\u5316\u3001\u5bb9\u5668\u5316\u3002<\/p>\n<h3 id=\"%E5%AE%B9%E5%99%A8%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F\">\u5bb9\u5668\u7684\u751f\u547d\u5468\u671f<\/h3>\n<p>\u5bb9\u5668\u7684\u751f\u547d\u5468\u671f\u662f\u5bb9\u5668\u53ef\u80fd\u5904\u4e8e\u7684\u72b6\u6001\u3002<\/p>\n<li>created&#xff1a;\u521d\u5efa\u72b6\u6001<\/li>\n<li>running&#xff1a;\u8fd0\u884c\u72b6\u6001<\/li>\n<li>stopped&#xff1a;\u505c\u6b62\u72b6\u6001<\/li>\n<li>paused&#xff1a; \u6682\u505c\u72b6\u6001<\/li>\n<li>deleted&#xff1a;\u5220\u9664\u72b6\u6001<\/li>\n<p>\u5404\u751f\u547d\u5468\u671f\u4e4b\u95f4\u7684\u8f6c\u6362\u5173\u7cfb\u5982\u56fe\u6240\u793a&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1312\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134927-6aafe467e4148.png\" width=\"3360\" \/><\/p>\n<p>docker create &#xff1a; \u521b\u5efa\u5bb9\u5668\u540e&#xff0c;\u4e0d\u7acb\u5373\u542f\u52a8\u8fd0\u884c&#xff0c;\u5bb9\u5668\u8fdb\u5165\u521d\u5efa\u72b6\u6001&#xff1b;<\/p>\n<p>docker run &#xff1a; \u521b\u5efa\u5bb9\u5668&#xff0c;\u5e76\u7acb\u5373\u542f\u52a8\u8fd0\u884c&#xff0c;\u8fdb\u5165\u8fd0\u884c\u72b6\u6001&#xff1b;<\/p>\n<p>docker start &#xff1a; \u5bb9\u5668\u8f6c\u4e3a\u8fd0\u884c\u72b6\u6001&#xff1b;<\/p>\n<p>docker stop &#xff1a; \u5bb9\u5668\u5c06\u8f6c\u5165\u505c\u6b62\u72b6\u6001&#xff1b;<\/p>\n<p>docker kill &#xff1a; \u5bb9\u5668\u5728\u6545\u969c&#xff08;\u6b7b\u673a&#xff09;\u65f6&#xff0c;\u6267\u884c kill&#xff08;\u65ad\u7535&#xff09;&#xff0c;\u5bb9\u5668\u8f6c\u5165\u505c\u6b62\u72b6\u6001&#xff0c;\u8fd9\u79cd \u64cd\u4f5c\u5bb9\u6613\u4e22\u5931\u6570\u636e&#xff0c;\u9664\u975e\u5fc5\u8981&#xff0c;\u5426\u5219\u4e0d\u5efa\u8bae\u4f7f\u7528&#xff1b;<\/p>\n<p>docker restart &#xff1a; \u91cd\u542f\u5bb9\u5668&#xff0c;\u5bb9\u5668\u8f6c\u5165\u8fd0\u884c\u72b6\u6001&#xff1b;<\/p>\n<p>docker pause &#xff1a; \u5bb9\u5668\u8fdb\u5165\u6682\u505c\u72b6\u6001&#xff1b;<\/p>\n<p>docker unpause &#xff1a; \u53d6\u6d88\u6682\u505c\u72b6\u6001&#xff0c;\u5bb9\u5668\u8fdb\u5165\u8fd0\u884c\u72b6\u6001&#xff1b;<\/p>\n<p>docker rm &#xff1a; \u5220\u9664\u5bb9\u5668&#xff0c;\u5bb9\u5668\u8f6c\u5165\u5220\u9664\u72b6\u6001\u3002<\/p>\n<p>killed by out-of-memory&#xff08;\u56e0\u5185\u5b58\u4e0d\u8db3\u88ab\u7ec8\u6b62&#xff09; &#xff1a;\u5bbf\u4e3b\u673a\u5185\u5b58\u88ab\u8017\u5c3d&#xff0c;\u4e5f\u88ab\u79f0\u4e3a OOM&#xff1a;<\/p>\n<\/p>\n<p>\u975e\u8ba1\u5212\u7ec8\u6b62 \u8fd9\u65f6\u9700\u8981\u6740\u6b7b\u6700\u5403\u5185\u5b58\u7684\u5bb9\u5668<\/p>\n<p>container process exitde&#xff08;\u5f02\u5e38\u7ec8\u6b62&#xff09;&#xff1a;\u51fa\u73b0\u5bb9\u5668\u88ab\u7ec8\u6b62\u540e&#xff0c;\u5c06\u8fdb\u5165 Should restart?\u9009 \u62e9\u64cd\u4f5c&#xff1a;<\/p>\n<ul>\n<li>yes \u9700\u8981\u91cd\u542f&#xff0c;\u5bb9\u5668\u6267\u884c start \u547d\u4ee4&#xff0c;\u8f6c\u4e3a\u8fd0\u884c\u72b6\u6001\u3002<\/li>\n<li>no \u4e0d\u9700\u8981\u91cd\u542f&#xff0c;\u5bb9\u5668\u8f6c\u4e3a\u505c\u6b62\u72b6\u6001<\/li>\n<\/ul>\n<h4 id=\"%E5%AE%B9%E5%99%A8%20OOM\">\u5bb9\u5668 OOM<\/h4>\n<p>Docker \u5728\u5904\u7406 OOM \u4e8b\u4ef6\u65f6\u5206\u4e3a\u4e09\u79cd\u60c5\u51b5<\/p>\n<p>&#xff08;1&#xff09;\u5982\u679c\u5bb9\u5668\u4e2d\u7684\u5e94\u7528\u8017\u5c3d\u4e86\u4e3b\u673a\u7cfb\u7edf\u5206\u914d\u7ed9\u5bb9\u5668\u7684\u5185\u5b58\u9650\u989d&#xff0c;\u5c31\u4f1a\u89e6\u53d1 OOM \u4e8b\u4ef6\u3002 \u4f8b\u5982&#xff0c;\u5728\u5bb9\u5668\u5f53\u4e2d&#xff0c;\u90e8\u7f72\u4e86\u4e00\u4e2a web \u670d\u52a1\u3002\u5047\u8bbe\u4e3b\u673a\u5206\u914d\u7ed9\u6b64\u5bb9\u5668\u7684\u5185\u5b58\u4e0a\u9650\u4e3a 1G&#xff0c; \u5f53\u811a\u672c\u7533\u8bf7\u7684\u5185\u5b58\u5927\u4e8e 1G \u65f6&#xff0c;\u6b64\u5bb9\u5668\u5c31\u4f1a\u89e6\u53d1 OOM \u4e8b\u4ef6\u3002\u800c\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u6b64\u5bb9 \u5668\u5c06\u4f1a\u88ab\u5f3a\u5236\u5173\u95ed\u3002<\/p>\n<p>\u4f46\u9700\u8981\u6ce8\u610f\u7684\u662f&#xff0c;\u6b64\u65f6\u5173\u95ed\u5bb9\u5668\u7684\u5e76\u975e\u662f Docker Daemon&#xff0c;\u800c\u662f\u5bbf\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u3002\u56e0 \u4e3a\u4e00\u4e2a\u5bb9\u5668\u5176\u5b9e\u5c31\u662f\u4e00\u7ec4\u8fd0\u884c\u5728\u5bbf\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u5f53\u4e2d\u7684\u8fdb\u7a0b&#xff0c;\u5bbf\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u901a\u8fc7 cgroups \u5bf9\u8fd9\u7ec4\u8fdb\u7a0b\u8bbe\u5b9a\u8d44\u6e90\u4e0a\u9650&#xff0c;\u5f53\u8fd9\u4e9b\u8fdb\u7a0b\u7533\u8bf7\u7684\u8d44\u6e90\u5230\u8fbe\u4e0a\u9650\u65f6&#xff0c;\u89e6\u53d1\u7684\u662f\u5bbf \u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u7684\u5185\u6838 OOM \u4e8b\u4ef6&#xff0c;\u56e0\u6b64\u6700\u7ec8\u662f\u7531\u5bbf\u4e3b\u673a\u5185\u6838\u6765\u5173\u95ed\u8fd9\u4e9b\u8fdb\u7a0b.<\/p>\n<p>(2) \u5982\u679c\u7528\u6237\u4e0d\u60f3\u5173\u95ed\u8fd9\u4e2a\u5bb9\u5668&#xff0c;\u90a3\u4e48\u53ef\u4ee5\u9009\u62e9&#8211;oom-kill-disable \u6765\u7981\u7528 OOM-Killer\u3002 \u4f7f\u7528\u6b64\u53c2\u6570\u65f6&#xff0c;\u4ecd\u9700\u8981\u6ce8\u610f&#xff0c;\u5982\u679c\u4f7f\u7528-m \u8bbe\u7f6e\u4e86\u6b64\u5bb9\u5668\u5185\u5b58\u4e0a\u9650&#xff0c;\u90a3\u4e48\u5f53\u5bb9\u5668\u5230\u8fbe\u5185 \u5b58\u8d44\u6e90\u4e0a\u9650\u65f6&#xff0c;\u4e3b\u673a\u4e0d\u4f1a\u5173\u95ed\u5bb9\u5668&#xff0c;\u4f46\u4e5f\u4e0d\u4f1a\u7ee7\u7eed\u5411\u6b64\u5bb9\u5668\u7ee7\u7eed\u5206\u914d\u8d44\u6e90&#xff0c;\u6b64\u65f6\u5bb9\u5668 \u5c06\u5904\u4e8e hung \u72b6\u6001\u3002\u53ea\u9700\u8981\u5c06\u6700\u574f\u7684\u60c5\u51b5\u5c01\u95ed\u5728\u4e00\u5b9a\u8303\u56f4\u4e4b\u5185&#xff0c;\u800c\u4e0d\u81f3\u4e8e\u8513\u5ef6\u51fa\u53bb\u3002<\/p>\n<p>(3)\u5982\u679c\u7528\u6237\u4f7f\u7528\u4e86&#8211;oom-kill-disable&#xff0c;\u4f46\u4e5f\u6ca1\u6709\u4f7f\u7528-m \u6765\u8bbe\u5b9a\u4e0a\u9650&#xff0c;\u56e0\u800c\u6b64\u65f6\u6b64\u5bb9\u5668 \u5c06\u4f1a\u5c3d\u53ef\u80fd\u591a\u5730\u4f7f\u7528\u4e3b\u673a\u5185\u5b58\u8d44\u6e90\u3002\u6362\u8a00\u4e4b&#xff0c;\u4e3b\u673a\u5185\u5b58\u6709\u591a\u5927&#xff0c;\u5b83\u5c31\u5c06\u7528\u591a\u5927\u3002<\/p>\n<h4 id=\"%E5%AE%B9%E5%99%A8%E5%BC%82%E5%B8%B8%E9%80%80%E5%87%BA\">\u5bb9\u5668\u5f02\u5e38\u9000\u51fa<\/h4>\n<p>\u6bcf\u4e2a\u5bb9\u5668\u5185\u90e8\u90fd\u5b58\u5728\u4e00\u4e2a Init \u8fdb\u7a0b&#xff0c;\u5bb9\u5668\u4e2d\u5176\u4ed6\u6240\u6709\u8fdb\u7a0b\u90fd\u662f\u6b64\u8fdb\u7a0b\u7684\u5b50\u8fdb\u7a0b\u3002\u8fd0\u884c \u7684\u5bb9\u5668\u662f\u56e0\u4e3a Init \u8fdb\u7a0b\u5728\u8fd0\u884c&#xff0c;\u5982\u679c\u4e00\u4e2a\u5b50\u8fdb\u7a0b\u56e0\u4e3a\u67d0\u79cd\u539f\u56e0\u9020\u6210\u4e86\u9000\u51fa&#xff0c;\u90a3\u4e48\u5176\u7236 \u8fdb\u7a0b\u4e5f\u4f1a\u540c\u6b65\u9000\u51fa&#xff0c;\u76f4\u81f3 Init \u8fdb\u7a0b\u4e5f\u9000\u51fa\u3002\u5f53 Init \u8fdb\u7a0b\u9000\u51fa\u65f6&#xff0c;\u4e5f\u5c31\u4ee3\u8868\u7740\u6b64\u5bb9\u5668\u88ab\u5173 \u95ed\u3002ocker \u76ee\u524d\u6ca1\u6709\u529e\u6cd5\u77e5\u9053\u6b64\u65f6\u7684\u8fdb\u7a0b\u9000\u51fa\u5c5e\u4e8e\u6b63\u5e38\u9000\u51fa\u8fd8\u662f\u5f02\u5e38\u9000\u51fa\u3002\u5f53\u51fa\u73b0\u5bb9\u5668 \u5173\u95ed\u60c5\u51b5\u65f6&#xff0c;Docker Daemon \u4f1a\u5c1d\u8bd5\u518d\u6b21\u91cd\u65b0\u5c06\u6b64\u5bb9\u5668\u7531 Stopped \u72b6\u6001\u8f6c\u4e3a Running \u72b6\u6001\u3002\u53ea\u6709\u8bbe\u7f6e\u4e86&#8211;restart \u53c2\u6570\u7684\u5bb9\u5668&#xff0c;Docker Daemon \u624d\u4f1a\u53bb\u5c1d\u8bd5\u542f\u52a8&#xff0c;\u5426\u5219\u5bb9\u5668 \u4f1a\u4fdd\u6301\u505c\u6b62\u72b6\u6001\u3002<\/p>\n<h4 id=\"%E5%AE%B9%E5%99%A8%E6%9A%82%E5%81%9C\">\u5bb9\u5668\u6682\u505c<\/h4>\n<p>Docker\u201c\u5265\u593a\u201d\u4e86\u6b64\u5bb9\u5668\u7684 CPU \u8d44\u6e90\u3002\u800c\u5176\u4ed6\u8d44\u6e90&#xff0c;\u5982 Memory \u8d44\u6e90\u3001Network \u8d44\u6e90 \u7b49\u8fd8\u4fdd\u7559\u672a\u52a8\u3002\u5982\u6b64\u4e00\u6765&#xff0c;\u5931\u53bb\u4e86 CPU \u8d44\u6e90\u7684\u8fdb\u7a0b&#xff0c;\u662f\u4e0d\u4f1a\u88ab\u4e3b\u673a\u5185\u6838\u7cfb\u7edf\u6240\u8c03\u5ea6\u7684&#xff0c;\u6240\u4ee5\u6b64\u5bb9\u5668\u5c31\u5904\u4e8e\u201c\u51b0\u5c01\u201d\u72b6\u6001\u3002<\/p>\n<h3 id=\"%E5%AE%B9%E5%99%A8%E5%91%BD%E4%BB%A4%E6%B8%85%E5%8D%95\">\u5bb9\u5668\u547d\u4ee4\u6e05\u5355<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"2528\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134929-6aafe469e82aa.png\" width=\"1760\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"2848\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134932-6aafe46c0600f.png\" width=\"1600\" \/><\/p>\n<h3 id=\"%E5%AE%B9%E5%99%A8%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3\">\u5bb9\u5668\u547d\u4ee4\u8be6\u89e3<\/h3>\n<h4 id=\"docker%20create\">docker create<\/h4>\n<p>\u529f\u80fd \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bb9\u5668\u4f46\u4e0d\u542f\u52a8\u5b83<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker create [OPTIONS] IMAGE [COMMAND] [ARG&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -i: \u4ee5\u4ea4\u4e92\u6a21\u5f0f\u8fd0\u884c\u5bb9\u5668&#xff0c;\u901a\u5e38\u4e0e -t \u540c\u65f6\u4f7f\u7528&#xff1b;<\/p>\n<p>&#xffee; -P: \u968f\u673a\u7aef\u53e3\u6620\u5c04&#xff0c;\u5bb9\u5668\u5185\u90e8\u7aef\u53e3\u968f\u673a\u6620\u5c04\u5230\u4e3b\u673a\u7684\u7aef\u53e3<\/p>\n<p>&#xffee; -p: \u6307\u5b9a\u7aef\u53e3\u6620\u5c04&#xff0c;\u683c\u5f0f\u4e3a&#xff1a;\u4e3b\u673a(\u5bbf\u4e3b)\u7aef\u53e3:\u5bb9\u5668\u7aef\u53e3<\/p>\n<p>&#xffee; -t: \u4e3a\u5bb9\u5668\u91cd\u65b0\u5206\u914d\u4e00\u4e2a\u4f2a\u8f93\u5165\u7ec8\u7aef&#xff0c;\u901a\u5e38\u4e0e -i \u540c\u65f6\u4f7f\u7528&#xff1b;<\/p>\n<p>&#xffee; &#8211;name&#061;&#034;nginx-lb&#034;: \u4e3a\u5bb9\u5668\u6307\u5b9a\u4e00\u4e2a\u540d\u79f0&#xff1b;<\/p>\n<p>&#xffee; -h &#034;mars&#034;: \u6307\u5b9a\u5bb9\u5668\u7684 hostname&#xff1b;<\/p>\n<p>&#xffee; -e username&#061;&#034;ritchie&#034;: \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf&#xff1b;<\/p>\n<p>&#xffee; &#8211;cpuset-cpus&#061;&#034;0-2&#034; or &#8211;cpuset-cpus&#061;&#034;0,1,2&#034;: \u7ed1\u5b9a\u5bb9\u5668\u5230\u6307\u5b9a CPU \u8fd0\u884c&#xff1b;<\/p>\n<p>&#xffee; -m :\u8bbe\u7f6e\u5bb9\u5668\u4f7f\u7528\u5185\u5b58\u6700\u5927\u503c&#xff1b;<\/p>\n<p>&#xffee; &#8211;network&#061;&#034;bridge&#034;: \u6307\u5b9a\u5bb9\u5668\u7684\u7f51\u7edc\u8fde\u63a5\u7c7b\u578b&#xff1b;<\/p>\n<p>&#xffee; &#8211;link&#061;[]: \u6dfb\u52a0\u94fe\u63a5\u5230\u53e6\u4e00\u4e2a\u5bb9\u5668&#xff1b;<\/p>\n<p>&#xffee; &#8211;volume , -v: \u7ed1\u5b9a\u4e00\u4e2a\u5377<\/p>\n<p>&#xffee; &#8211;rm :shell \u9000\u51fa\u7684\u65f6\u5019\u81ea\u52a8\u5220\u9664\u5bb9\u5668<\/p>\n<p>&#xffee; &#8211;restart:\u81ea\u52a8\u91cd\u542f<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker create &#8211;name mynginx nginx:latest<\/p>\n<h4 id=\"docker%20run\">docker run<\/h4>\n<p>\u529f\u80fd \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5bb9\u5668\u5e76\u8fd0\u884c\u4e00\u4e2a\u547d\u4ee4<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker run [OPTIONS] IMAGE [COMMAND]\u00a0[ARG&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -d: \u540e\u53f0\u8fd0\u884c\u5bb9\u5668&#xff0c;\u5e76\u8fd4\u56de\u5bb9\u5668 ID&#xff1b;\u6bd4 create \u591a\u4e86\u8fd9\u4e2a\u53c2\u6570<\/p>\n<p>&#xffee; -i: \u4ee5\u4ea4\u4e92\u6a21\u5f0f\u8fd0\u884c\u5bb9\u5668&#xff0c;\u901a\u5e38\u4e0e -t \u540c\u65f6\u4f7f\u7528&#xff1b;<\/p>\n<p>&#xffee; -P: \u968f\u673a\u7aef\u53e3\u6620\u5c04&#xff0c;\u5bb9\u5668\u5185\u90e8\u7aef\u53e3\u968f\u673a\u6620\u5c04\u5230\u4e3b\u673a\u7684\u7aef\u53e3<\/p>\n<p>&#xffee; -p: \u6307\u5b9a\u7aef\u53e3\u6620\u5c04&#xff0c;\u683c\u5f0f\u4e3a&#xff1a;\u4e3b\u673a(\u5bbf\u4e3b)\u7aef\u53e3:\u5bb9\u5668\u7aef\u53e3<\/p>\n<p>&#xffee; -t: \u4e3a\u5bb9\u5668\u91cd\u65b0\u5206\u914d\u4e00\u4e2a\u4f2a\u8f93\u5165\u7ec8\u7aef&#xff0c;\u901a\u5e38\u4e0e -i \u540c\u65f6\u4f7f\u7528&#xff1b;<\/p>\n<p>&#xffee; &#8211;name&#061;&#034;nginx-lb&#034;: \u4e3a\u5bb9\u5668\u6307\u5b9a\u4e00\u4e2a\u540d\u79f0&#xff1b;<\/p>\n<p>&#xffee; -h &#034;mars&#034;: \u6307\u5b9a\u5bb9\u5668\u7684 hostname&#xff1b;<\/p>\n<p>&#xffee; -e username&#061;&#034;ritchie&#034;: \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf&#xff1b;<\/p>\n<p>&#xffee; &#8211;cpuset-cpus&#061;&#034;0-2&#034; or &#8211;cpuset-cpus&#061;&#034;0,1,2&#034;: \u7ed1\u5b9a\u5bb9\u5668\u5230\u6307\u5b9a CPU \u8fd0\u884c&#xff1b;<\/p>\n<p>&#xffee; -m :\u8bbe\u7f6e\u5bb9\u5668\u4f7f\u7528\u5185\u5b58\u6700\u5927\u503c&#xff1b;<\/p>\n<p>&#xffee; &#8211;network&#061;&#034;bridge&#034;: \u6307\u5b9a\u5bb9\u5668\u7684\u7f51\u7edc\u8fde\u63a5\u7c7b\u578b&#xff1b;<\/p>\n<p>&#xffee; &#8211;link&#061;[]: \u6dfb\u52a0\u94fe\u63a5\u5230\u53e6\u4e00\u4e2a\u5bb9\u5668&#xff1b;<\/p>\n<p>&#xffee; &#8211;volume , -v: \u7ed1\u5b9a\u4e00\u4e2a\u5377<\/p>\n<p>&#xffee; &#8211;rm :shell \u9000\u51fa\u7684\u65f6\u5019\u81ea\u52a8\u5220\u9664\u5bb9\u5668<\/p>\n<p>&#xffee; &#8211;restart:\u81ea\u52a8\u91cd\u542f<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u4f7f\u7528 docker \u955c\u50cf nginx:latest \u4ee5\u540e\u53f0\u6a21\u5f0f\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668,\u5e76\u5c06\u5bb9\u5668\u547d\u540d\u4e3a mynginx\u3002<\/p>\n<p>docker run &#8211;name mynginx -d nginx:latest<\/p>\n<\/p>\n<p>#\u4f7f\u7528\u955c\u50cf nginx:latest&#xff0c;\u4ee5\u540e\u53f0\u6a21\u5f0f\u542f\u52a8\u4e00\u4e2a\u5bb9\u5668,\u5c06\u5bb9\u5668\u7684 80 \u7aef\u53e3\u6620\u5c04\u5230\u4e3b \u673a\u7684 80 \u7aef\u53e3,\u4e3b\u673a\u7684\u76ee\u5f55 \/data \u6620\u5c04\u5230\u5bb9\u5668\u7684 \/data\u3002<\/p>\n<p>docker run -p 80:80 -v \/data:\/data -d nginx:latest<\/p>\n<h4 id=\"docker%20ps\">docker ps<\/h4>\n<p>\u529f\u80fd \u5217\u51fa\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker ps [OPTIONS]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -a :\u663e\u793a\u6240\u6709\u7684\u5bb9\u5668&#xff0c;\u5305\u62ec\u672a\u8fd0\u884c\u7684\u3002<\/p>\n<p>&#xffee; -f :\u6839\u636e\u6761\u4ef6\u8fc7\u6ee4\u663e\u793a\u7684\u5185\u5bb9\u3002<\/p>\n<p>&#xffee; &#8211;format :\u6307\u5b9a\u8fd4\u56de\u503c\u7684\u6a21\u677f\u6587\u4ef6\u3002\u5982 json \u6216\u8005 table<\/p>\n<p>&#xffee; -l :\u663e\u793a latest \u7684\u5bb9\u5668\u3002<\/p>\n<p>&#xffee; -n :\u5217\u51fa\u6700\u8fd1\u521b\u5efa\u7684 n \u4e2a\u5bb9\u5668\u3002<\/p>\n<p>&#xffee; &#8211;no-trunc :\u4e0d\u622a\u65ad\u8f93\u51fa\u3002<\/p>\n<p>&#xffee; -q :\u9759\u9ed8\u6a21\u5f0f&#xff0c;\u53ea\u663e\u793a\u5bb9\u5668\u7f16\u53f7\u3002<\/p>\n<p>&#xffee; -s :\u663e\u793a\u603b\u7684\u6587\u4ef6\u5927\u5c0f\u3002<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker ps -a<\/p>\n<h4 id=\"docker%20logs\">docker logs<\/h4>\n<p>\u529f\u80fd \u67e5\u770b\u5bb9\u5668\u65e5\u5fd7<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker logs [OPTIONS] CONTAINER<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -f ,&#8211;follow: \u8ddf\u8e2a\u65e5\u5fd7\u8f93\u51fa<\/p>\n<p>&#xffee; &#8211;since :\u663e\u793a\u67d0\u4e2a\u5f00\u59cb\u65f6\u95f4\u7684\u6240\u6709\u65e5\u5fd7<\/p>\n<p>&#xffee; -t,&#8211;timestamps : \u663e\u793a\u65f6\u95f4\u6233<\/p>\n<p>&#xffee; -n&#xff0c;&#8211;tail :\u4ec5\u5217\u51fa\u6700\u65b0 N \u6761\u5bb9\u5668\u65e5\u5fd7<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u8ddf\u8e2a\u67e5\u770b\u5bb9\u5668 mynginx \u7684\u65e5\u5fd7\u8f93\u51fa\u3002<\/p>\n<p>docker logs -f mynginx1<\/p>\n<\/p>\n<p>#\u67e5\u770b\u5bb9\u5668 mynginx \u4ece 2016 \u5e74 7 \u6708 1 \u65e5\u540e\u7684\u6700\u65b0 10 \u6761\u65e5\u5fd7\u3002<\/p>\n<p>docker logs &#8211;since&#061;&#034;2016-07-01&#034; &#8211;tail&#061;10 mynginx<\/p>\n<h4 id=\"docker%20attach\">docker attach<\/h4>\n<p>\u529f\u80fd\u00a0\u8fde\u63a5\u5230\u6b63\u5728\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker attach [OPTIONS] CONTAINER<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; &#8211;sig-proxy&#xff1a;\u662f\u5426\u5c06\u6240\u6709\u4fe1\u53f7\u4ee3\u7406&#xff0c;\u9ed8\u8ba4\u662f true&#xff0c;\u5982\u679c\u8bbe\u7f6e\u4e3a false&#xff0c;\u9000\u51fa\u7684 \u8bdd\u4e0d\u4f1a\u5f71\u54cd\u5bb9\u5668&#xff0c;\u5426\u5219\u9000\u51fa\u4f1a\u5bfc\u81f4\u5bb9\u5668\u9000\u51fa\u3002<\/p>\n<p>\u6837\u4f8b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1696\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134934-6aafe46ec67b7.png\" width=\"2336\" \/><\/p>\n<p>\u663e\u793a\u62a5\u6587\u4e3a<\/p>\n<p>CONTAINER ID: \u5bb9\u5668 ID\u3002<\/p>\n<p>IMAGE: \u4f7f\u7528\u7684\u955c\u50cf\u3002<\/p>\n<p>COMMAND: \u542f\u52a8\u5bb9\u5668\u65f6\u8fd0\u884c\u7684\u547d\u4ee4\u3002<\/p>\n<p>CREATED: \u5bb9\u5668\u7684\u521b\u5efa\u65f6\u95f4\u3002<\/p>\n<p>STATUS: \u5bb9\u5668\u72b6\u6001\u3002<\/p>\n<p>PORTS: \u5bb9\u5668\u7684\u7aef\u53e3\u4fe1\u606f\u548c\u4f7f\u7528\u7684\u8fde\u63a5\u7c7b\u578b&#xff08;tcp\\\\udp&#xff09;\u3002<\/p>\n<p>NAMES: \u81ea\u52a8\u5206\u914d\u7684\u5bb9\u5668\u540d\u79f0\u3002<\/p>\n<h4 id=\"docker%20exec\">docker exec<\/h4>\n<p>\u529f\u80fd \u5728\u5bb9\u5668\u4e2d\u6267\u884c\u547d\u4ee4<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker exec [OPTIONS] CONTAINER COMMAND [ARG&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -d :\u5206\u79bb\u6a21\u5f0f: \u5728\u540e\u53f0\u8fd0\u884c<\/p>\n<p>&#xffee; -i :\u5373\u4f7f\u6ca1\u6709\u9644\u52a0\u4e5f\u4fdd\u6301 STDIN \u6253\u5f00<\/p>\n<p>&#xffee; -t :\u5206\u914d\u4e00\u4e2a\u4f2a\u7ec8\u7aef<\/p>\n<p>&#xffee; -e :\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<p>&#xffee; -u,&#8211;user :\u6307\u5b9a\u7528\u6237 &#034;[:]&#034;<\/p>\n<p>&#xffee; -w,&#8211;workdir:\u6307\u5b9a\u5de5\u4f5c\u76ee\u5f55<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u5728\u5bb9\u5668 mynginx \u4e2d\u4ee5\u4ea4\u4e92\u6a21\u5f0f\u6267\u884c echo:<\/p>\n<p>docker exec -it mynginx echo &#034;Hello bit&#034;<\/p>\n<\/p>\n<p>#\u5728\u5bb9\u5668 mynginx \u4e2d\u4ee5\u4ea4\u4e92\u6a21\u5f0f\u6253\u5f00 shell:<\/p>\n<p>docker exec -it mynginx bash<\/p>\n<\/p>\n<p>#\u901a\u8fc7 id \u8fdb\u53bb&#xff0c;docker ps \u53ef\u4ee5\u770b\u5230\u5bb9\u5668 id<\/p>\n<p>docker exec -it 5706674cc67e bash<\/p>\n<h4 id=\"docker%20start\">docker start<\/h4>\n<p>\u529f\u80fd \u542f\u52a8\u505c\u6b62\u7684\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker start [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker start mynginx<\/p>\n<h4 id=\"docker%20stop\">docker stop<\/h4>\n<p>\u529f\u80fd \u505c\u6b62\u8fd0\u884c\u7684\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker stop [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -s :\u53d1\u9001\u7684\u4fe1\u53f7<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker stop mynginx<\/p>\n<h4 id=\"docker%20restart\">docker restart<\/h4>\n<p>\u529f\u80fd \u91cd\u542f\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker restart [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -s :\u53d1\u9001\u4fe1\u53f7<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker restart mynginx<\/p>\n<h4 id=\"docker%20kill\">docker kill<\/h4>\n<p>\u529f\u80fd \u5f3a\u5236\u9000\u51fa\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker kill [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -s :\u53d1\u9001\u7684\u4fe1\u53f7<\/p>\n<p>\u2022 \u6ce8\u610f\u4e8b\u9879&#xff1a;Docker stop \u53d1\u9001\u7684\u662f SIGTERM \u4fe1\u53f7&#xff0c;docker kill \u53d1\u9001\u7684\u662f SIGKILL \u4fe1\u53f7<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker kill mynginx<\/p>\n<h4 id=\"docker%20top\">docker top<\/h4>\n<p>\u529f\u80fd \u67e5\u770b\u5bb9\u5668\u4e2d\u8fd0\u884c\u7684\u8fdb\u7a0b\u4fe1\u606f&#xff0c;\u652f\u6301 ps \u547d\u4ee4\u53c2\u6570\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker top CONTAINER [ps OPTIONS]<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879:\u5bb9\u5668\u8fd0\u884c\u65f6\u4e0d\u4e00\u5b9a\u6709\/bin\/bash \u7ec8\u7aef\u6765\u4ea4\u4e92\u6267\u884c top \u547d\u4ee4&#xff0c;\u800c\u4e14\u5bb9\u5668\u8fd8\u4e0d\u4e00\u5b9a\u6709 top \u547d\u4ee4&#xff0c;\u53ef\u4ee5\u4f7f\u7528 docker top \u6765\u5b9e\u73b0\u67e5\u770b container \u4e2d\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u67e5\u770b\u5bb9\u5668\u8fdb\u7a0b\u4fe1\u606f<\/p>\n<p>docker top mynginx<\/p>\n<h4 id=\"docker%20stats\">docker stats<\/h4>\n<p>\u529f\u80fd \u663e\u793a\u5bb9\u5668\u8d44\u6e90\u7684\u4f7f\u7528\u60c5\u51b5&#xff0c;\u5305\u62ec&#xff1a;CPU\u3001\u5185\u5b58\u3001\u7f51\u7edc I\/O \u7b49\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker stats [OPTIONS] [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; &#8211;all , -a :\u663e\u793a\u6240\u6709\u7684\u5bb9\u5668&#xff0c;\u5305\u62ec\u672a\u8fd0\u884c\u7684\u3002<\/p>\n<p>&#xffee; &#8211;format :\u6307\u5b9a\u8fd4\u56de\u503c\u7684\u6a21\u677f\u6587\u4ef6\u3002\u5982 table,json<\/p>\n<p>&#xffee; &#8211;no-stream :\u5c55\u793a\u5f53\u524d\u72b6\u6001\u5c31\u76f4\u63a5\u9000\u51fa\u4e86&#xff0c;\u4e0d\u518d\u5b9e\u65f6\u66f4\u65b0\u3002<\/p>\n<p>&#xffee; &#8211;no-trunc :\u4e0d\u622a\u65ad\u8f93\u51fa\u3002<\/p>\n<p>\u8fd4\u56de\u62a5\u6587<\/p>\n<p>CONTAINER ID \u4e0e NAME: \u5bb9\u5668 ID \u4e0e\u540d\u79f0\u3002<\/p>\n<p>CPU % \u4e0e MEM %: \u5bb9\u5668\u4f7f\u7528\u7684 CPU \u548c\u5185\u5b58\u7684\u767e\u5206\u6bd4\u3002<\/p>\n<p>MEM USAGE \/ LIMIT: \u5bb9\u5668\u6b63\u5728\u4f7f\u7528\u7684\u603b\u5185\u5b58&#xff0c;\u4ee5\u53ca\u5141\u8bb8\u4f7f\u7528\u7684\u5185\u5b58\u603b\u91cf\u3002<\/p>\n<p>NET I\/O: \u5bb9\u5668\u901a\u8fc7\u5176\u7f51\u7edc\u63a5\u53e3\u53d1\u9001\u548c\u63a5\u6536\u7684\u6570\u636e\u91cf\u3002<\/p>\n<p>BLOCK I\/O: \u5bb9\u5668\u4ece\u4e3b\u673a\u4e0a\u7684\u5757\u8bbe\u5907\u8bfb\u53d6\u548c\u5199\u5165\u7684\u6570\u636e\u91cf\u3002<\/p>\n<p>PIDs: \u5bb9\u5668\u521b\u5efa\u7684\u8fdb\u7a0b\u6216\u7ebf\u7a0b\u6570<\/p>\n<p>\u6837\u4f8b<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1600\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134938-6aafe4727e967.png\" width=\"2464\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"165\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134941-6aafe4754a716.png\" width=\"798\" \/><\/p>\n<h4 id=\"docker%20container%20inspect\">docker container inspect<\/h4>\n<p>\u529f\u80fd \u67e5\u770b\u5bb9\u5668\u8be6\u7ec6\u4fe1\u606f<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker container inspect [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -f :\u6307\u5b9a\u8fd4\u56de\u503c\u7684\u6a21\u677f\u6587\u4ef6\u3002\u5982 table\u3001json<\/p>\n<p>&#xffee; -s :\u663e\u793a\u603b\u7684\u6587\u4ef6\u5927\u5c0f\u3002<\/p>\n<p>\u6ce8\u610f\u4e8b\u9879&#xff1a;docker inspect \u4f1a\u81ea\u52a8\u68c0\u67e5\u662f\u955c\u50cf\u8fd8\u662f\u5bb9\u5668\u7136\u540e\u663e\u793a\u76f8\u4fe1\u4fe1\u606f<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker container inspect mynginx<\/p>\n<h4 id=\"docker%20port\">docker port<\/h4>\n<p>\u529f\u80fd \u7528\u4e8e\u5217\u51fa\u6307\u5b9a\u7684\u5bb9\u5668\u7684\u7aef\u53e3\u6620\u5c04&#xff0c;\u6216\u8005\u67e5\u627e\u5c06 PRIVATE_PORT NAT \u5230\u9762\u5411\u516c\u4f17 \u7684\u7aef\u53e3\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker port CONTAINER [PRIVATE_PORT[\/PROTO]]<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker port mynginx<\/p>\n<h4 id=\"docker%20cp\">docker cp<\/h4>\n<p>\u529f\u80fd \u5728\u5bb9\u5668\u548c\u5bbf\u4e3b\u673a\u4e4b\u95f4\u62f7\u8d1d\u6587\u4ef6<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH| &#8211;<\/p>\n<p>docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u5c06\u4e3b\u673a\/www\/\u76ee\u5f55\u62f7\u8d1d\u5230\u5bb9\u5668 mynginx \u7684\/www \u76ee\u5f55\u4e0b\u3002<\/p>\n<p>docker cp \/www\/ mynginx:\/www\/<\/p>\n<\/p>\n<p>#\u5c06\u5bb9\u5668\/www\/\u76ee\u5f55\u62f7\u8d1d\u5230\u4e3b\u673a\u7684\/wwwbak \u76ee\u5f55\u4e0b\u3002<\/p>\n<p>docker cp mynginx:\/www\/ \/wwwbak\/<\/p>\n<h4 id=\"docker%20diff\">docker diff<\/h4>\n<p>\u529f\u80fd \u68c0\u67e5\u5bb9\u5668\u91cc\u6587\u4ef6\u7ed3\u6784\u7684\u66f4\u6539<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker diff CONTAINER<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker diff mynginx<\/p>\n<h4 id=\"docker%20commit\">docker commit<\/h4>\n<p>\u529f\u80fd \u4ece\u5bb9\u5668\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u955c\u50cf<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]<\/p>\n<p>\u53c2\u6570<\/p>\n<p>&#xffee; -a :\u63d0\u4ea4\u7684\u955c\u50cf\u4f5c\u8005&#xff1b;<\/p>\n<p>&#xffee; -c :\u4f7f\u7528 Dockerfile \u6307\u4ee4\u6765\u521b\u5efa\u955c\u50cf&#xff1b;\u53ef\u4ee5\u4fee\u6539\u542f\u52a8\u6307\u4ee4<\/p>\n<p>&#xffee; -m :\u63d0\u4ea4\u65f6\u7684\u8bf4\u660e\u6587\u5b57&#xff1b;<\/p>\n<p>&#xffee; -p :\u5728 commit \u65f6&#xff0c;\u5c06\u5bb9\u5668\u6682\u505c<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker commit c3f279d17e0a maxhou\/mynginx:v01<\/p>\n<h4 id=\"docker%20pause\">docker pause<\/h4>\n<p>\u529f\u80fd \u6682\u505c\u5bb9\u5668\u4e2d\u6240\u6709\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker pause CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker pause mynginx<\/p>\n<h4 id=\"docker%20unpause\">docker unpause<\/h4>\n<p>\u529f\u80fd \u6062\u590d\u5bb9\u5668\u4e2d\u6240\u6709\u7684\u8fdb\u7a0b\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker unpause CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker unpause mynginx<\/p>\n<h4 id=\"docker%20rm\">docker rm<\/h4>\n<p>\u529f\u80fd \u5220\u9664\u505c\u6b62\u7684\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker rm [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -f :\u901a\u8fc7 SIGKILL \u4fe1\u53f7\u5f3a\u5236\u5220\u9664\u4e00\u4e2a\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\u3002<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u5220\u9664 mynginx \u5bb9\u5668<\/p>\n<p>docker stop mynginx<\/p>\n<p>docker rm mynginx<\/p>\n<\/p>\n<p>#\u5220\u9664\u6240\u6709\u505c\u6b62\u7684\u5bb9\u5668<\/p>\n<p>docker rm $(docker ps -a -q)<\/p>\n<h4 id=\"docker%20export\">docker export<\/h4>\n<p>\u529f\u80fd \u5bfc\u51fa\u5bb9\u5668\u5185\u5bb9\u4e3a tar \u6587\u4ef6<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker export [OPTIONS] CONTAINER<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -o:\u5199\u5165\u5230\u6587\u4ef6<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u5bfc\u51fa nginx \u4e3a tar<\/p>\n<p>docker export -o mynginx202203.tar mynginx<\/p>\n<h4 id=\"docker%20wait\">docker wait<\/h4>\n<p>\u529f\u80fd \u963b\u585e\u8fd0\u884c\u76f4\u5230\u5bb9\u5668\u505c\u6b62&#xff0c;\u7136\u540e\u6253\u5370\u51fa\u5b83\u7684\u9000\u51fa\u4ee3\u7801\u3002<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker wait CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker wait mynginx<\/p>\n<h4 id=\"docker%20rename\">docker rename<\/h4>\n<p>\u529f\u80fd \u91cd\u547d\u540d\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker rename CONTAINER NEW_NAME<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker rename mynginx myweb<\/p>\n<h4 id=\"docker%20container%20prune\">docker container prune<\/h4>\n<p>\u529f\u80fd \u5220\u9664\u6240\u6709\u505c\u6b62\u7684\u5bb9\u5668<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker container prune [OPTIONS]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; -f, &#8211;force&#xff1a;\u4e0d\u63d0\u793a\u662f\u5426\u8fdb\u884c\u786e\u8ba4<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>docker container prune<\/p>\n<h4 id=\"docker%20update\">docker update<\/h4>\n<p>\u529f\u80fd \u66f4\u65b0\u5bb9\u5668\u914d\u7f6e<\/p>\n<p>\u8bed\u6cd5<\/p>\n<p>docker update [OPTIONS] CONTAINER [CONTAINER&#8230;]<\/p>\n<p>\u5173\u952e\u53c2\u6570<\/p>\n<p>&#xffee; &#8211;cpus&#xff1a;cpu \u6570\u91cf<\/p>\n<p>&#xffee; &#8211;cpuset-cpus :\u4f7f\u7528\u54ea\u4e9b cpu<\/p>\n<p>&#xffee; &#8211;memory :\u5185\u5b58\u9650\u5236<\/p>\n<p>&#xffee; &#8211;memory-swap&#xff1a;\u4ea4\u6362\u5185\u5b58<\/p>\n<p>&#xffee; &#8211;cpu-period :\u662f\u7528\u6765\u6307\u5b9a\u5bb9\u5668\u5bf9 CPU \u7684\u4f7f\u7528\u8981\u5728\u591a\u957f\u65f6\u95f4\u5185\u505a\u4e00\u6b21\u91cd\u65b0\u5206 \u914d<\/p>\n<p>&#xffee; &#8211;cpu-quota&#xff1a;\u662f\u7528\u6765\u6307\u5b9a\u5728\u8fd9\u4e2a\u5468\u671f\u5185&#xff0c;\u6700\u591a\u53ef\u4ee5\u6709\u591a\u5c11\u65f6\u95f4\u7528\u6765\u8dd1\u8fd9\u4e2a\u5bb9 \u5668<\/p>\n<p>\u6837\u4f8b<\/p>\n<p>#\u66f4\u65b0\u5185\u5b58<\/p>\n<p>docker update -m 400m myweb<\/p>\n<h3 id=\"%E5%AE%B9%E5%99%A8%E6%93%8D%E4%BD%9C%E6%A1%88%E4%BE%8B\">\u5bb9\u5668\u64cd\u4f5c\u6848\u4f8b<\/h3>\n<h4 id=\"%E5%AE%B9%E5%99%A8%E4%BA%A4%E4%BA%92%E6%A8%A1%E5%BC%8F\">\u5bb9\u5668\u4ea4\u4e92\u6a21\u5f0f<\/h4>\n<h5 id=\"attached%20%E6%A8%A1%E5%BC%8F\">attached \u6a21\u5f0f<\/h5>\n<p># \u901a\u8fc7 nginx \u955c\u50cf\u521b\u5efa\u4e00\u4e2a\u5bb9\u5668&#xff0c; \u6620\u5c04 80 \u7aef\u53e3<br \/>\n[zsc&#064;VM-8-12-centos ~]$ docker container run -p 80:80 nginx <\/p>\n<p>-p 80:80 \u8868\u793a\u7aef\u53e3\u6620\u5c04&#xff0c;\u7b2c\u4e00\u4e2a\u7aef\u53e3\u8868\u793a\u6620\u5c04\u5230\u5bbf\u4e3b\u673a\u7684\u7aef\u53e3&#xff0c;\u7b2c\u4e8c\u4e2a\u7aef\u53e3\u8868\u793a\u6620 \u5c04\u5230 Docker \u5bb9\u5668\u7684\u7aef\u53e3\u3002<\/p>\n<p>\u2022 \u901a\u8fc7\u4e0a\u8ff0\u65b9\u5f0f\u521b\u5efa\u5bb9\u5668&#xff0c;\u5c31\u662f attached \u6a21\u5f0f&#xff0c;\u8fd9\u6837\u5bb9\u5668\u4f1a\u5728\u524d\u53f0\u8fd0\u884c<\/p>\n<p>\u2022 \u8bbf\u95ee\u670d\u52a1\u5668\u7f51\u5740\u7684\u65f6\u5019&#xff0c;\u6bcf\u8bbf\u95ee\u4e00\u6b21&#xff0c;\u547d\u4ee4\u7a97\u53e3\u5c31\u4f1a\u6253\u5370\u4e00\u6b21\u65e5\u5fd7&#xff0c;Docker \u5bb9\u5668 \u7684\u65e5\u5fd7\u4f1a\u5b9e\u65f6\u7684\u5c55\u73b0\u5230\u7a97\u53e3\u5e76\u4e14\u5360\u7528\u6b64\u7aef\u53e3<\/p>\n<p>\u2022 \u5982\u679c\u662f\u5728 Linux \u670d\u52a1\u5668\u4e0a&#xff0c;\u6309 Ctrl&#043;C \u5c31\u4f1a\u505c\u6b62\u6389 Docker \u670d\u52a1&#xff0c;\u5f88\u5bb9\u6613\u8bef\u64cd\u4f5c&#xff0c; \u6240\u4ee5\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u66f4\u597d\u7684&#xff0c;\u66f4\u7a33\u5b9a\u7684\u6a21\u5f0f&#xff0c;\u5bf9\u5e94\u7684\u662f detached \u6a21\u5f0f<\/p>\n<p>\u2022 attached \u6a21\u5f0f\u4ec5\u9002\u7528\u4e8e\u5bb9\u5668\u548c\u7a0b\u5e8f\u7684\u8c03\u8bd5\u9636\u6bb5<\/p>\n<h5 id=\"detached%20%E6%A8%A1%E5%BC%8F\">detached \u6a21\u5f0f<\/h5>\n<p>\u5728 docker container run -p 80:80 nginx \u547d\u4ee4\u57fa\u7840\u4e0a\u52a0\u4e00\u4e2a-d \u6216\u8005&#8211;detach \u9009\u9879\u8868\u793a detached \u6a21\u5f0f&#xff0c; \u5373\u5728\u540e\u53f0\u6267\u884c<\/p>\n<p>\u2022 \u5728\u540e\u53f0\u8fd0\u884c&#xff0c;\u542f\u52a8\u540e\u53ea\u663e\u793a\u5bb9\u5668 ID&#xff0c;\u5e76\u4e14\u53ef\u4ee5\u8f93\u5165\u4efb\u4f55\u547d\u4ee4<\/p>\n<p>\u2022 \u5c31\u7b97\u5173\u6389\u7a97\u53e3\u4f9d\u7136\u7ee7\u7eed\u8fd0\u884c&#xff0c;\u505c\u6b62\u548c\u5220\u9664\u5bb9\u5668\u90fd\u9700\u8981\u4f7f\u7528 shell \u547d\u4ee4&#xff0c;\u51cf\u5c11\u4e86\u5f88\u591a \u7684\u8bef\u64cd\u4f5c<\/p>\n<p>\u2022 \u6bd4\u8d77 attached \u6a21\u5f0f\u66f4\u5efa\u8bae\u4f7f\u7528<\/p>\n<p>detached \u6a21\u5f0f\u8f6c attached \u6a21\u5f0f&#xff1a;<\/p>\n<p>docker container attach XXX<\/p>\n<h5 id=\"interactive%20%E6%A8%A1%E5%BC%8F\">interactive \u6a21\u5f0f<\/h5>\n<p>\u5f53\u6211\u4eec\u521b\u5efa\u597d\u4e00\u4e2a\u5bb9\u5668\u4e4b\u540e&#xff0c; \u53ef\u80fd\u9700\u8981\u53bb\u5bb9\u5668\u5185\u90e8\u83b7\u53d6\u4e00\u4e9b\u4fe1\u606f\u6216\u6267\u884c\u4e00\u4e9b\u547d\u4ee4&#xff0c;\u5c31 \u9700\u8981\u8fdb\u5165\u5230\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u3002\u4f8b\u5982\u521b\u5efa\u4e00\u4e2a Ubuntu \u5bb9\u5668\u4e4b\u540e&#xff0c;\u9700\u8981\u5230\u7cfb\u7edf\u91cc\u8f93\u5165\u5404\u79cd Shell \u547d\u4ee4\u548c\u7cfb\u7edf\u8fdb\u884c\u4ea4\u4e92\u5c31\u9700\u8981\u8fdb\u5165\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u624d\u53ef\u4ee5\u5b8c\u6210<\/p>\n<p>\u521b\u5efa\u8fd0\u884c\u5bb9\u5668\u5e76\u8fdb\u5165\u5230\u4ea4\u4e92\u6a21\u5f0f<\/p>\n<p>docker container run -it nginx sh<\/p>\n<p>&#xffee; -i&#xff1a;\u4fdd\u6301\u5bb9\u5668\u8fd0\u884c\u3002\u901a\u5e38\u4e0e -t \u540c\u65f6\u4f7f\u7528&#xff0c;\u52a0\u5165 it \u8fd9\u4e24\u4e2a\u53c2\u6570\u540e&#xff0c;\u5bb9\u5668\u521b\u5efa\u540e\u81ea \u52a8\u8fdb\u5165\u5bb9\u5668\u4e2d&#xff0c;\u9000\u51fa\u5bb9\u5668\u540e&#xff0c;\u5bb9\u5668\u81ea\u52a8\u5173\u95ed<\/p>\n<p>&#xffee; -t&#xff1a;\u4e3a\u5bb9\u5668\u91cd\u65b0\u5206\u914d\u4e00\u4e2a\u4f2a\u8f93\u5165\u7ec8\u7aef&#xff0c;\u901a\u5e38\u4e0e -i \u540c\u65f6\u4f7f\u7528<\/p>\n<h3 id=\"%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98\">\u5e38\u89c1\u95ee\u9898<\/h3>\n<h4 id=\"docker%20create%E3%80%81docker%20start%20%E5%92%8C%20docker%20run%20%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F\">docker create\u3001docker start \u548c docker run \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/h4>\n<p>docker create \u547d\u4ee4\u4ece Docker \u6620\u50cf\u521b\u5efa\u4e00\u4e2a\u5168\u65b0\u7684\u5bb9\u5668\u3002\u4f46\u662f&#xff0c;\u5b83\u4e0d\u4f1a\u7acb\u5373\u8fd0\u884c\u5b83\u3002<\/p>\n<p>docker start \u547d\u4ee4\u5c06\u542f\u52a8\u4efb\u4f55\u5df2\u505c\u6b62\u7684\u5bb9\u5668\u3002\u5982\u679c\u4f7f\u7528 docker create \u547d\u4ee4\u521b\u5efa\u5bb9\u5668&#xff0c; \u5219\u53ef\u4ee5\u4f7f\u7528\u6b64\u547d\u4ee4\u542f\u52a8\u5b83\u3002<\/p>\n<p>docker run \u547d\u4ee4\u662f\u521b\u5efa\u548c\u542f\u52a8\u7684\u7ec4\u5408&#xff0c;\u56e0\u4e3a\u5b83\u521b\u5efa\u4e86\u4e00\u4e2a\u65b0\u5bb9\u5668\u5e76\u7acb\u5373\u542f\u52a8\u5b83\u3002\u5b9e\u9645 \u4e0a&#xff0c;\u5982\u679c docker run \u547d\u4ee4\u5728\u60a8\u7684\u7cfb\u7edf\u4e0a\u627e\u4e0d\u5230\u4e0a\u8ff0\u6620\u50cf&#xff0c;\u5b83\u53ef\u4ee5\u4ece Docker Hub \u4e2d\u63d0 \u53d6\u6620\u50cf\u3002<\/p>\n<h4 id=\"docker%20import%20%E5%92%8C%20docker%20load%20%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%EF%BC%9F\">docker import \u548c docker load \u6709\u4ec0\u4e48\u533a\u522b&#xff1f;<\/h4>\n<p>\u60f3\u8981\u4e86\u89e3 docker load \u4e0e docker import \u547d\u4ee4\u7684\u533a\u522b&#xff0c;\u8fd8\u5fc5\u987b\u77e5\u9053 docker save \u4e0e docker export \u547d\u4ee4&#xff1a;<\/p>\n<p>\u2022 docker save images_name&#xff1a;\u5c06\u4e00\u4e2a\u955c\u50cf\u5bfc\u51fa\u4e3a\u6587\u4ef6&#xff0c;\u518d\u4f7f\u7528 docker load \u547d \u4ee4\u5c06\u6587\u4ef6\u5bfc\u5165\u4e3a\u4e00\u4e2a\u955c\u50cf&#xff0c;\u4f1a\u4fdd\u5b58\u8be5\u955c\u50cf\u7684\u7684\u6240\u6709\u5386\u53f2\u8bb0\u5f55\u3002\u6bd4 docker export \u547d\u4ee4 \u5bfc\u51fa\u7684\u6587\u4ef6\u5927&#xff0c;\u5f88\u597d\u7406\u89e3&#xff0c;\u56e0\u4e3a\u4f1a\u4fdd\u5b58\u955c\u50cf\u7684\u6240\u6709\u5386\u53f2\u8bb0\u5f55\u3002<\/p>\n<p>\u2022 docker export container_id&#xff1a;\u5c06\u4e00\u4e2a\u5bb9\u5668\u5bfc\u51fa\u4e3a\u6587\u4ef6&#xff0c;\u518d\u4f7f\u7528 docker import \u547d\u4ee4\u5c06\u5bb9\u5668\u5bfc\u5165\u6210\u4e3a\u4e00\u4e2a\u65b0\u7684\u955c\u50cf&#xff0c;\u4f46\u662f\u76f8\u6bd4 docker save \u547d\u4ee4&#xff0c;\u5bb9\u5668\u6587\u4ef6 \u4f1a\u4e22\u5931\u6240\u6709\u5143\u6570\u636e\u548c\u5386\u53f2\u8bb0\u5f55&#xff0c;\u4ec5\u4fdd\u5b58\u5bb9\u5668\u5f53\u65f6\u7684\u72b6\u6001&#xff0c;\u76f8\u5f53\u4e8e\u865a\u62df\u673a\u5feb\u7167\u3002<\/p>\n<p>\u65e2\u53ef\u4ee5\u4f7f\u7528 docker load \u547d\u4ee4\u6765\u5bfc\u5165\u955c\u50cf\u5e93\u5b58\u50a8\u6587\u4ef6\u5230\u672c\u5730\u955c\u50cf\u5e93&#xff0c;\u4e5f\u53ef\u4ee5\u4f7f\u7528 docker import \u547d\u4ee4\u6765\u5bfc\u5165\u4e00\u4e2a\u5bb9\u5668\u5feb\u7167\u5230\u672c\u5730\u955c\u50cf\u5e93\u3002<\/p>\n<p>\u4e24\u8005\u7684\u533a\u522b\u5728\u4e8e\u5bb9\u5668\u5feb\u7167\u5c06\u4f1a\u4e22\u5f03\u6240\u6709\u7684\u5386\u53f2\u8bb0\u5f55\u548c\u5143\u6570\u636e\u4fe1\u606f&#xff0c;\u800c\u955c\u50cf\u5b58\u50a8\u6587\u4ef6\u5c06 \u4fdd\u5b58\u5b8c\u6574\u8bb0\u5f55&#xff0c;\u4f53\u79ef\u4e5f\u4f1a\u66f4\u5927\u3002<\/p>\n<h3 id=\"docker%20rm%20%26%20docker%20rmi%20%26%20docker%20prune%20%E7%9A%84%E5%B7%AE%E5%BC%82%EF%BC%9F\">docker rm &amp; docker rmi &amp; docker prune \u7684\u5dee\u5f02&#xff1f;<\/h3>\n<p>docker rm &#xff1a; \u5220\u9664\u4e00\u4e2a\u6216\u591a\u4e2a\u5bb9\u5668<\/p>\n<p>docker rmi : \u5220\u9664\u4e00\u4e2a\u6216\u591a\u4e2a\u955c\u50cf<\/p>\n<p>docker prune&#xff1a; \u7528\u6765\u5220\u9664\u4e0d\u518d\u4f7f\u7528\u7684 docker \u5bf9\u8c61<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f308;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u79e6jh__https:\/\/blog.csdn.net\/qinjh_?spm1010.2135.3001.5343 &#x1f525;\u00a0\u7cfb\u5217\u4e13\u680f&#xff1a;Docker_\u79e6jh_\u7684\u535a\u5ba2-CSDN\u535a\u5ba2 \u200b\u200b\u200b\u200b\u200b<br \/>\n\u76ee\u5f55<br \/>\nDocker Container&#xff08;\u5bb9\u5668&#xff09;<br \/>\n\u4ec0\u4e48\u662f\u5bb9\u5668&#xff1f;<br \/>\n\u5bb9\u5668\u751f\u6d3b\u6848\u4f8b<br \/>\n\u4e3a\u4ec0\u4e48\u9700\u8981\u5bb9\u5668&#xff1f;<br \/>\n\u5bb9\u5668\u7684\u751f\u547d\u5468\u671f<br \/>\n\u5bb9\u5668 OOM<br \/>\n\u5bb9\u5668\u5f02\u5e38\u9000\u51fa<br \/>\n\u5bb9\u5668\u6682\u505c <\/p>\n","protected":false},"author":2,"featured_media":108055,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,121,44],"topic":[],"class_list":["post-108064","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-docker","tag-121","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Docker\u3011\u5bb9\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/108064.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Docker\u3011\u5bb9\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f308;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u79e6jh__https:\/\/blog.csdn.net\/qinjh_?spm1010.2135.3001.5343 &#x1f525;\u00a0\u7cfb\u5217\u4e13\u680f&#xff1a;Docker_\u79e6jh_\u7684\u535a\u5ba2-CSDN\u535a\u5ba2 \u200b\u200b\u200b\u200b\u200b \u76ee\u5f55 Docker Container&#xff08;\u5bb9\u5668&#xff09; \u4ec0\u4e48\u662f\u5bb9\u5668&#xff1f; \u5bb9\u5668\u751f\u6d3b\u6848\u4f8b \u4e3a\u4ec0\u4e48\u9700\u8981\u5bb9\u5668&#xff1f; \u5bb9\u5668\u7684\u751f\u547d\u5468\u671f \u5bb9\u5668 OOM \u5bb9\u5668\u5f02\u5e38\u9000\u51fa \u5bb9\u5668\u6682\u505c\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/108064.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-20T13:49:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134923-6aafe4636b9a8.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108064.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/108064.html\",\"name\":\"\u3010Docker\u3011\u5bb9\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-20T13:49:42+00:00\",\"dateModified\":\"2026-09-20T13:49:42+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/108064.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/108064.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/108064.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Docker\u3011\u5bb9\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010Docker\u3011\u5bb9\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/108064.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Docker\u3011\u5bb9\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f308;\u4e2a\u4eba\u4e3b\u9875&#xff1a;\u79e6jh__https:\/\/blog.csdn.net\/qinjh_?spm1010.2135.3001.5343 &#x1f525;\u00a0\u7cfb\u5217\u4e13\u680f&#xff1a;Docker_\u79e6jh_\u7684\u535a\u5ba2-CSDN\u535a\u5ba2 \u200b\u200b\u200b\u200b\u200b \u76ee\u5f55 Docker Container&#xff08;\u5bb9\u5668&#xff09; \u4ec0\u4e48\u662f\u5bb9\u5668&#xff1f; \u5bb9\u5668\u751f\u6d3b\u6848\u4f8b \u4e3a\u4ec0\u4e48\u9700\u8981\u5bb9\u5668&#xff1f; \u5bb9\u5668\u7684\u751f\u547d\u5468\u671f \u5bb9\u5668 OOM \u5bb9\u5668\u5f02\u5e38\u9000\u51fa \u5bb9\u5668\u6682\u505c","og_url":"https:\/\/www.wsisp.com\/helps\/108064.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-20T13:49:42+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/09\/20260920134923-6aafe4636b9a8.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/108064.html","url":"https:\/\/www.wsisp.com\/helps\/108064.html","name":"\u3010Docker\u3011\u5bb9\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-20T13:49:42+00:00","dateModified":"2026-09-20T13:49:42+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/108064.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/108064.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/108064.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Docker\u3011\u5bb9\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/108064","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=108064"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/108064\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/108055"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=108064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=108064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=108064"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=108064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}