{"id":61985,"date":"2026-01-19T01:50:09","date_gmt":"2026-01-18T17:50:09","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/61985.html"},"modified":"2026-01-19T01:50:09","modified_gmt":"2026-01-18T17:50:09","slug":"%e7%ac%ac%e4%ba%8c%e9%98%b6%e6%ae%b5%ef%bc%9a%e7%8e%a9%e8%bd%ac%e5%ae%b9%e5%99%a8-%e5%9f%ba%e7%a1%80%e5%91%bd%e4%bb%a4%e7%af%87","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/61985.html","title":{"rendered":"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7)"},"content":{"rendered":"<p>\u592a\u68d2\u4e86&#xff01;\u65e2\u7136\u4f60\u5df2\u7ecf\u51c6\u5907\u597d\u4e86&#xff0c;\u6211\u4eec\u5c31\u6765\u8fd0\u884c Docker \u4e16\u754c\u7684\u201c\u5f00\u95e8\u4eea\u5f0f\u201d\u3002<\/p>\n<p>\u5c31\u50cf\u5b66\u7f16\u7a0b\u90fd\u8981\u6253\u5370 Hello World \u4e00\u6837&#xff0c;Docker \u4e5f\u6709\u4e00\u4e2a\u4e13\u95e8\u7528\u6765\u6d4b\u8bd5\u7684\u955c\u50cf&#xff0c;\u540d\u5b57\u5c31\u53eb hello-world\u3002<\/p>\n<hr \/>\n<h4>2.1 Hello World<\/h4>\n<p>\u8bf7\u5728\u4f60\u7684\u7ec8\u7aef (Terminal\/CMD\/PowerShell) \u4e2d\u8f93\u5165\u4e0b\u9762\u8fd9\u884c\u795e\u5723\u7684\u547d\u4ee4&#xff0c;\u7136\u540e\u6309\u56de\u8f66&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run hello-world<\/p>\n<h5>\u4f60\u4f1a\u770b\u5230\u4ec0\u4e48&#xff1f;<\/h5>\n<p>\u5982\u679c\u4e00\u5207\u987a\u5229&#xff0c;\u5c4f\u5e55\u4e0a\u4f1a\u5237\u51fa\u4e00\u5806\u82f1\u6587&#xff0c;\u5176\u4e2d\u6700\u6838\u5fc3\u7684\u662f\u8fd9\u4e00\u53e5&#xff1a;<\/p>\n<p>Hello from Docker!<br \/>\nThis message shows that your installation appears to be working correctly.<\/p>\n<p>&#x1f389; \u606d\u559c&#xff01;\u4f60\u521a\u521a\u6210\u529f\u8fd0\u884c\u4e86\u4f60\u7684\u7b2c\u4e00\u4e2a Docker \u5bb9\u5668&#xff01;<\/p>\n<hr \/>\n<h4>\u521a\u521a\u53d1\u751f\u4e86\u4ec0\u4e48&#xff1f;&#xff08;\u5e95\u5c42\u89e3\u6790&#xff09;<\/h4>\n<p>\u867d\u7136\u53ea\u6572\u4e86\u4e00\u884c\u547d\u4ee4&#xff0c;\u4f46 Docker \u5728\u540e\u53f0\u9ed8\u9ed8\u5e2e\u4f60\u505a\u4e86 4 \u4ef6\u4e8b&#xff08;\u8bf7\u5bf9\u7167\u4e4b\u524d\u5b66\u7684\u201c\u4e09\u5251\u5ba2\u201d\u6982\u5ff5&#xff09;&#xff1a;<\/p>\n<li>\u5bfb\u627e\u955c\u50cf&#xff1a;Docker \u5ba2\u6237\u7aef\u68c0\u67e5\u4f60\u7684\u7535\u8111\u91cc\u6709\u6ca1\u6709 hello-world \u8fd9\u4e2a\u955c\u50cf\u3002\n<ul>\n<li>\u7ed3\u679c&#xff1a; \u7b2c\u4e00\u6b21\u8fd0\u884c&#xff0c;\u80af\u5b9a\u6ca1\u6709 (Unable to find image&#8230; locally)\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4e0b\u8f7d\u955c\u50cf (Pull)&#xff1a;\u65e2\u7136\u672c\u5730\u6ca1\u6709&#xff0c;Docker \u5c31\u81ea\u52a8\u53bb Docker Hub&#xff08;\u4ed3\u5e93&#xff09;\u628a\u4f60\u4e0b\u8f7d\u4e86\u4e0b\u6765\u3002\n<ul>\n<li>\u5c4f\u5e55\u63d0\u793a&#xff1a; Pulling from library\/hello-world&#8230;<\/li>\n<\/ul>\n<\/li>\n<li>\u542f\u52a8\u5bb9\u5668 (Run)&#xff1a;\u4e0b\u8f7d\u5b8c\u540e&#xff0c;Docker \u57fa\u4e8e\u8fd9\u4e2a\u955c\u50cf\u521b\u5efa\u4e86\u4e00\u4e2a\u5bb9\u5668\u5e76\u542f\u52a8\u4e86\u5b83\u3002<\/li>\n<li>\u6267\u884c\u5e76\u9000\u51fa&#xff1a;\u8fd9\u4e2a\u5bb9\u5668\u91cc\u7684\u7a0b\u5e8f\u5f88\u7b80\u5355&#xff0c;\u5b83\u7684\u552f\u4e00\u4f5c\u7528\u5c31\u662f\u6253\u5370\u51fa\u90a3\u6bb5 \u201cHello from Docker!\u201d \u7684\u6587\u5b57&#xff0c;\u6253\u5370\u5b8c\u4e4b\u540e&#xff0c;\u7a0b\u5e8f\u7ed3\u675f&#xff0c;\u5bb9\u5668\u4e5f\u5c31\u81ea\u52a8\u505c\u6b62\u4e86\u3002<\/li>\n<hr \/>\n<h4>\u9a8c\u8bc1\u4e00\u4e0b<\/h4>\n<p>\u4f60\u53ef\u4ee5\u8f93\u5165\u4e0b\u9762\u8fd9\u4e2a\u547d\u4ee4&#xff0c;\u67e5\u770b\u521a\u624d\u4e0b\u8f7d\u7684\u955c\u50cf\u662f\u5426\u8fd8\u5728\u7535\u8111\u91cc&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> images<\/p>\n<p>\u4f60\u5e94\u8be5\u80fd\u770b\u5230 hello-world \u5728\u5217\u8868\u4e2d&#xff0c;\u5927\u5c0f\u53ea\u6709\u5341\u51e0 KB\u3002<\/p>\n<hr \/>\n<p>\u8fd9\u4e2a\u65f6\u5019\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;\u201c\u8fd9\u4e2a\u5bb9\u5668\u8fd0\u884c\u5b8c\u5c31\u9000\u51fa\u4e86&#xff0c;\u90a3\u5982\u679c\u6211\u60f3\u8fd0\u884c\u4e00\u4e2a\u4e00\u76f4\u5728\u540e\u53f0\u8dd1\u7684\u670d\u52a1&#xff08;\u6bd4\u5982\u7f51\u7ad9&#xff09;\u8be5\u600e\u4e48\u529e&#xff1f;\u201d<\/p>\n<hr \/>\n<p>\u597d\u7684&#xff0c;\u8fdb\u5165 2.2&#xff01;\u8fd9\u4e00\u8282\u975e\u5e38\u5b9e\u7528\u3002<\/p>\n<p>\u521a\u624d\u7684 hello-world \u8dd1\u5b8c\u5c31\u201c\u6b7b\u201d\u4e86&#xff08;\u9000\u51fa&#xff09;&#xff0c;\u4f46\u5b9e\u9645\u5de5\u4f5c\u4e2d&#xff0c;\u6211\u4eec\u7684 Web \u670d\u52a1&#xff08;\u6bd4\u5982\u7f51\u7ad9\u3001\u6570\u636e\u5e93&#xff09;\u662f\u9700\u8981\u4e00\u76f4\u8fd0\u884c\u7684\u3002<\/p>\n<p>\u4e3a\u4e86\u6f14\u793a&#xff0c;\u6211\u4eec\u6362\u4e00\u4e2a\u66f4\u5389\u5bb3\u7684\u955c\u50cf&#xff1a;Nginx&#xff08;\u4e00\u4e2a\u8457\u540d\u7684 Web \u670d\u52a1\u5668&#xff09;\u3002<\/p>\n<p>\u8bf7\u6253\u5f00\u7ec8\u7aef&#xff0c;\u51c6\u5907\u597d\u8ddf\u6211\u4e00\u8d77\u6572\u547d\u4ee4&#xff01;<\/p>\n<hr \/>\n<h4>2.2 \u5bb9\u5668\u7684\u751f\u547d\u5468\u671f\u7ba1\u7406<\/h4>\n<p>\u6211\u4eec\u8981\u5b66\u4e60\u5982\u4f55\u8ba9\u5bb9\u5668&#xff1a;\u540e\u53f0\u8fd0\u884c\u3001\u67e5\u770b\u72b6\u6001\u3001\u505c\u6b62\u3001\u542f\u52a8\u3001\u5220\u9664\u3002<\/p>\n<h5>1. \u542f\u52a8\u4e00\u4e2a\u201c\u957f\u751f\u4e0d\u8001\u201d\u7684\u5bb9\u5668<\/h5>\n<p>\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token parameter variable\">&#8211;name<\/span> my-nginx nginx<\/p>\n<p>\u547d\u4ee4\u89e3\u6790&#xff08;\u91cd\u70b9&#xff09;&#xff1a;<\/p>\n<ul>\n<li>docker run&#xff1a;\u521b\u5efa\u5e76\u542f\u52a8\u5bb9\u5668\u3002<\/li>\n<li>-d (Detached)&#xff1a;\u540e\u53f0\u8fd0\u884c\u6a21\u5f0f\u3002\u8fd9\u610f\u5473\u7740\u5bb9\u5668\u542f\u52a8\u540e\u4f1a\u9ed8\u9ed8\u5728\u540e\u53f0\u5de5\u4f5c&#xff0c;\u4e0d\u4f1a\u5360\u7528\u4f60\u7684\u7ec8\u7aef\u7a97\u53e3&#xff08;\u4e0d\u50cf hello-world \u90a3\u6837\u5360\u5c4f&#xff09;\u3002<\/li>\n<li>&#8211;name my-nginx&#xff1a;\u7ed9\u8fd9\u4e2a\u5bb9\u5668\u8d77\u4e2a\u540d\u5b57\u53eb my-nginx\u3002\u5982\u679c\u4e0d\u5199&#xff0c;Docker \u4f1a\u968f\u673a\u7ed9\u5b83\u8d77\u4e2a\u602a\u540d\u5b57&#xff08;\u6bd4\u5982 angry_einstein&#xff09;&#xff0c;\u5f88\u4e0d\u65b9\u4fbf\u7ba1\u7406\u3002<\/li>\n<li>nginx&#xff1a;\u955c\u50cf\u7684\u540d\u5b57\u3002<\/li>\n<\/ul>\n<p>\u6ce8&#xff1a;\u7b2c\u4e00\u6b21\u8fd0\u884c Docker \u4f1a\u5148\u4ece\u4ed3\u5e93\u4e0b\u8f7d Nginx \u955c\u50cf&#xff0c;\u7a0d\u7b49\u7247\u523b\u3002<\/p>\n<h5>2. \u67e5\u770b\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668 (ps)<\/h5>\n<p>\u600e\u4e48\u77e5\u9053\u5b83\u662f\u4e0d\u662f\u771f\u7684\u5728\u8dd1&#xff1f;\u8f93\u5165&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> <span class=\"token function\">ps<\/span><\/p>\n<p>\u4f60\u4f1a\u770b\u5230\u7c7b\u4f3c\u8fd9\u6837\u7684\u5217\u8868&#xff1a;<\/p>\n<ul>\n<li>CONTAINER ID&#xff1a;\u5bb9\u5668\u7684\u8eab\u4efd\u8bc1\u53f7&#xff08;\u968f\u673a\u4e71\u7801&#xff09;\u3002<\/li>\n<li>IMAGE&#xff1a;\u7528\u7684\u54ea\u4e2a\u955c\u50cf (nginx)\u3002<\/li>\n<li>STATUS&#xff1a;\u72b6\u6001\u3002\u5982\u679c\u770b\u5230 Up x seconds&#xff0c;\u8bf4\u660e\u5b83\u6b63\u5728\u5065\u5eb7\u8fd0\u884c&#xff01;<\/li>\n<li>NAMES&#xff1a;\u4f60\u521a\u624d\u8d77\u7684 my-nginx\u3002<\/li>\n<\/ul>\n<h5>3. \u505c\u6b62\u5bb9\u5668 (stop)<\/h5>\n<p>\u73a9\u591f\u4e86&#xff0c;\u60f3\u8ba9\u5b83\u4f11\u606f\u4e00\u4e0b\u3002\u8f93\u5165&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> stop my-nginx<\/p>\n<p>\u8fd9\u65f6\u5019\u4f60\u518d\u8f93 docker ps&#xff0c;\u4f60\u4f1a\u53d1\u73b0\u5217\u8868\u662f\u7a7a\u7684\u3002<br \/>\n\u4e0d\u7528\u614c&#xff0c;\u5bb9\u5668\u6ca1\u4e22&#xff0c;\u53ea\u662f\u5173\u673a\u4e86\u3002<\/p>\n<h5>4. \u67e5\u770b\u6240\u6709\u5bb9\u5668&#xff08;\u5305\u62ec\u5173\u673a\u7684&#xff09;<\/h5>\n<p>\u8f93\u5165&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> <span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-a<\/span><\/p>\n<p>(\u6ce8\u610f\u591a\u4e86\u4e2a -a&#xff0c;\u610f\u601d\u662f all)<\/p>\n<p>\u4f60\u4f1a\u770b\u5230 my-nginx \u8fd8\u5728&#xff0c;\u4f46\u662f\u72b6\u6001\u53d8\u6210\u4e86 Exited&#xff08;\u5df2\u9000\u51fa&#xff09;\u3002<\/p>\n<h5>5. \u518d\u6b21\u542f\u52a8 (start) &amp; \u91cd\u542f (restart)<\/h5>\n<ul>\n<li>\u5f00\u673a&#xff1a;docker start my-nginx<\/li>\n<li>\u91cd\u542f&#xff08;\u6bd4\u5982\u4fee\u6539\u4e86\u914d\u7f6e\u60f3\u5237\u65b0&#xff09;&#xff1a;docker restart my-nginx<\/li>\n<\/ul>\n<h5>6. \u5220\u9664\u5bb9\u5668 (rm)<\/h5>\n<p>\u5982\u679c\u4e0d\u60f3\u8981\u8fd9\u4e2a\u5bb9\u5668\u4e86&#xff0c;\u60f3\u628a\u5b83\u6254\u8fdb\u5783\u573e\u6876\u3002<\/p>\n<p>\u5c1d\u8bd5\u76f4\u63a5\u5220\u9664&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> <span class=\"token function\">rm<\/span> my-nginx<\/p>\n<p>\u62a5\u9519\u4e86\u5417&#xff1f; \u5e94\u8be5\u4f1a\u63d0\u793a&#xff1a;You cannot remove a running container&#8230;<br \/>\n\u89c4\u5219&#xff1a;Docker \u4e3a\u4e86\u4fdd\u62a4\u4f60&#xff0c;\u4e0d\u80fd\u76f4\u63a5\u5220\u9664\u6b63\u5728\u8fd0\u884c\u7684\u5bb9\u5668\u3002<\/p>\n<p>\u6b63\u786e\u7684\u5220\u9664\u59ff\u52bf&#xff1a;<\/p>\n<li>\u5148\u505c\u6b62&#xff1a;docker stop my-nginx<\/li>\n<li>\u518d\u5220\u9664&#xff1a;docker rm my-nginx<\/li>\n<li>(\u66b4\u529b\u6cd5&#xff1a;\u5982\u679c\u4e0d\u60f3\u8981\u505c\u6b62&#xff0c;\u5f3a\u884c\u5220\u9664\u53ef\u4ee5\u7528 docker rm -f my-nginx&#xff0c;-f \u4ee3\u8868 force)<\/li>\n<hr \/>\n<h4>\u5c0f\u7ed3<\/h4>\n<p>\u8fd9\u4e00\u8282\u4f60\u638c\u63e1\u4e86 Docker \u7684\u201c\u9065\u63a7\u5668\u201d&#xff1a;<\/p>\n<ul>\n<li>docker run -d&#xff1a;\u540e\u53f0\u542f\u52a8<\/li>\n<li>docker ps&#xff1a;\u770b\u6b63\u5728\u8dd1\u7684<\/li>\n<li>docker ps -a&#xff1a;\u770b\u6240\u6709\u7684&#xff08;\u5305\u62ec\u6302\u6389\u7684&#xff09;<\/li>\n<li>docker stop\/start&#xff1a;\u5173\u673a\/\u5f00\u673a<\/li>\n<li>docker rm&#xff1a;\u5220\u9664\u5bb9\u5668&#xff08;\u5c38\u4f53&#xff09;<\/li>\n<\/ul>\n<hr \/>\n<p>\u5b9e\u64cd\u4efb\u52a1&#xff1a;<br \/>\n\u8bf7\u5b8c\u6574\u8d70\u4e00\u904d\u4e0a\u9762\u7684\u6d41\u7a0b&#xff1a;\u542f\u52a8 -&gt; \u67e5\u770b -&gt; \u505c\u6b62 -&gt; \u5220\u9664\u3002<br \/>\n\u5f53\u4f60\u7684 docker ps -a \u5217\u8868\u91cc\u5e72\u5e72\u51c0\u51c0&#xff0c;\u6ca1\u6709 my-nginx \u7684\u65f6\u5019&#xff0c;\u6211\u4eec\u6765\u770b\u770b\u600e\u4e48\u770b\u5bb9\u5668\u91cc\u9762\u53d1\u751f\u4e86\u4ec0\u4e48&#xff08;\u6bd4\u5982\u67e5\u770b\u62a5\u9519\u65e5\u5fd7&#xff09;\u3002<\/p>\n<hr \/>\n<p>\u5f88\u597d&#xff0c;\u8fdb\u5165 2.3&#xff01;<\/p>\n<p>\u8fd9\u4e00\u8282\u975e\u5e38\u5173\u952e\u3002\u5f88\u591a\u521d\u5b66\u8005\u6700\u5927\u7684\u56f0\u60d1\u5c31\u662f&#xff1a;\u201c\u5bb9\u5668\u5728\u540e\u53f0\u8dd1&#xff0c;\u6211\u600e\u4e48\u77e5\u9053\u5b83\u6709\u6ca1\u6709\u62a5\u9519&#xff1f;\u6211\u600e\u4e48\u8fdb\u53bb\u4fee\u6539\u6587\u4ef6&#xff1f;\u201d<\/p>\n<p>\u4e3a\u4e86\u6f14\u793a&#xff0c;\u6211\u4eec\u9700\u8981\u5148\u628a\u521a\u624d\u5220\u6389\u7684 my-nginx \u91cd\u65b0\u590d\u6d3b\u3002\u8bf7\u5148\u8fd0\u884c&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> run <span class=\"token parameter variable\">-d<\/span> <span class=\"token parameter variable\">&#8211;name<\/span> my-nginx nginx<\/p>\n<hr \/>\n<h4>2.3 \u4e0e\u5bb9\u5668\u4ea4\u4e92<\/h4>\n<h5>1. \u67e5\u770b\u65e5\u5fd7 (Logs) \u2014\u2014 \u5b83\u662f\u76d1\u63a7\u6444\u50cf\u5934<\/h5>\n<p>\u5f53\u5bb9\u5668\u5728\u540e\u53f0 (-d) \u8fd0\u884c\u65f6&#xff0c;\u4f60\u770b\u4e0d\u89c1\u5b83\u7684\u8f93\u51fa\u3002\u5982\u679c\u7a0b\u5e8f\u5d29\u4e86&#xff0c;\u6216\u8005\u4f60\u60f3\u770b\u8c01\u8bbf\u95ee\u4e86\u4f60\u7684\u7f51\u7ad9&#xff0c;\u5c31\u8981\u67e5\u65e5\u5fd7\u3002<\/p>\n<p>\u547d\u4ee4&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> logs my-nginx<\/p>\n<p>\u4f60\u4f1a\u770b\u5230\u5c4f\u5e55\u4e0a\u6253\u5370\u51fa\u4e86\u4e00\u4e9b\u4fe1\u606f&#xff08;\u5982\u679c\u4f60\u8fd8\u6ca1\u8bbf\u95ee\u8fc7\u5b83&#xff0c;\u53ef\u80fd\u4fe1\u606f\u5f88\u5c11&#xff09;\u3002<\/p>\n<p>\u9ad8\u7ea7\u7528\u6cd5&#xff1a;\u5b9e\u65f6\u76d1\u63a7 (-f)<br \/>\n\u5c31\u50cf Linux \u7684 tail -f \u4e00\u6837&#xff0c;\u4f60\u53ef\u4ee5\u5b9e\u65f6\u76ef\u7740\u65e5\u5fd7\u770b&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> logs <span class=\"token parameter variable\">-f<\/span> my-nginx<\/p>\n<p>(\u6b64\u65f6\u5149\u6807\u4f1a\u505c\u5728\u90a3\u91cc\u95ea\u70c1&#xff0c;\u5982\u679c\u6709\u65b0\u65e5\u5fd7\u4f1a\u7acb\u523b\u8df3\u51fa\u6765\u3002\u6309 Ctrl &#043; C \u53ef\u4ee5\u9000\u51fa\u76d1\u63a7\u6a21\u5f0f\u3002)<\/p>\n<h5>2. \u8fdb\u5165\u5bb9\u5668\u5185\u90e8 (Exec) \u2014\u2014 \u5b83\u662f\u4efb\u610f\u95e8<\/h5>\n<p>\u8fd9\u662f Docker \u6700\u9177\u7684\u529f\u80fd\u4e4b\u4e00\u3002\u867d\u7136\u5bb9\u5668\u662f\u4e00\u4e2a\u5c01\u95ed\u7684\u76d2\u5b50&#xff0c;\u4f46\u4f60\u53ef\u4ee5\u968f\u65f6\u201c\u7a7f\u68ad\u201d\u8fdb\u53bb\u3002<\/p>\n<p>\u547d\u4ee4&#xff08;\u80cc\u4e0b\u6765&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> <span class=\"token builtin class-name\">exec<\/span> <span class=\"token parameter variable\">-it<\/span> my-nginx <span class=\"token function\">bash<\/span><\/p>\n<p>\u547d\u4ee4\u89e3\u6790&#xff1a;<\/p>\n<ul>\n<li>exec&#xff1a;\u6267\u884c\u547d\u4ee4\u3002<\/li>\n<li>-it&#xff1a;\u8fd9\u662f\u4e24\u4e2a\u53c2\u6570 -i (\u4ea4\u4e92\u5f0f) \u548c -t (\u4f2a\u7ec8\u7aef) \u7684\u7f29\u5199\u3002\u7b80\u5355\u8bf4&#xff0c;\u52a0\u4e0a\u5b83&#xff0c;\u4f60\u624d\u80fd\u50cf\u7528 SSH \u767b\u5f55\u670d\u52a1\u5668\u4e00\u6837\u5728\u91cc\u9762\u6572\u547d\u4ee4\u3002<\/li>\n<li>bash&#xff1a;\u8fd9\u662f\u4f60\u60f3\u5728\u5bb9\u5668\u91cc\u8fd0\u884c\u7684\u7a0b\u5e8f\u3002\u8fd9\u91cc\u6211\u4eec\u8fd0\u884c bash (\u6216\u8005 sh)&#xff0c;\u4e5f\u5c31\u662f\u542f\u52a8\u4e00\u4e2a\u547d\u4ee4\u884c\u7ec8\u7aef\u3002<\/li>\n<\/ul>\n<p>\u5f53\u4f60\u56de\u8f66\u540e&#xff1a;<br \/>\n\u4f60\u4f1a\u53d1\u73b0\u547d\u4ee4\u884c\u7684\u63d0\u793a\u7b26\u53d8\u4e86&#xff01;\u53d8\u6210\u4e86\u7c7b\u4f3c root&#064;8a2b3c4d5e6f:\/# \u7684\u6837\u5b50\u3002<br \/>\n\u606d\u559c&#xff0c;\u4f60\u73b0\u5728\u5df2\u7ecf\u8eab\u5904\u5bb9\u5668\u5185\u90e8\u4e86&#xff01; &#x1f632;<\/p>\n<p>\u5728\u91cc\u9762\u968f\u4fbf\u901b\u901b&#xff1a;<br \/>\n\u4f60\u53ef\u4ee5\u8f93\u5165 Linux \u547d\u4ee4\u770b\u770b&#xff1a;<\/p>\n<ul>\n<li>ls&#xff1a;\u770b\u770b\u6587\u4ef6\u76ee\u5f55\u3002<\/li>\n<li>cat \/etc\/nginx\/nginx.conf&#xff1a;\u770b\u770b Nginx \u7684\u914d\u7f6e\u6587\u4ef6\u3002<\/li>\n<li>ps&#xff1a;\u770b\u770b\u91cc\u9762\u7684\u8fdb\u7a0b&#xff08;\u4f60\u4f1a\u53d1\u73b0\u91cc\u9762\u975e\u5e38\u5e72\u51c0&#xff0c;\u53ef\u80fd\u53ea\u6709 Nginx \u5728\u8dd1&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u600e\u4e48\u51fa\u6765&#xff1f;<br \/>\n\u8f93\u5165&#xff1a;<\/p>\n<p><span class=\"token builtin class-name\">exit<\/span><\/p>\n<p>\u4f60\u5c31\u56de\u5230\u4e86\u4f60\u539f\u672c\u7684\u7535\u8111\u7ec8\u7aef\u3002<\/p>\n<hr \/>\n<h4>\u26a0\ufe0f \u4e00\u4e2a\u5e38\u89c1\u7684\u5751<\/h4>\n<p>\u6709\u4e9b\u4e3a\u4e86\u6781\u81f4\u7cbe\u7b80\u7684\u955c\u50cf&#xff08;\u6bd4\u5982 alpine \u7248\u672c&#xff09;&#xff0c;\u91cc\u9762\u53ef\u80fd\u6ca1\u6709 bash\u3002<br \/>\n\u5982\u679c\u4f60\u8f93\u5165\u4e0a\u9762\u547d\u4ee4\u62a5\u9519 executable file not found&#xff0c;\u8bf7\u5c1d\u8bd5\u628a bash \u6362\u6210 sh&#xff1a;<\/p>\n<p><span class=\"token function\">docker<\/span> <span class=\"token builtin class-name\">exec<\/span> <span class=\"token parameter variable\">-it<\/span> my-nginx <span class=\"token function\">sh<\/span><\/p>\n<hr \/>\n<h4>\u7b2c\u4e8c\u9636\u6bb5\u603b\u7ed3 (\u73a9\u8f6c\u5bb9\u5668)<\/h4>\n<p>\u4f60\u73b0\u5728\u5df2\u7ecf\u5b66\u4f1a\u4e86&#xff1a;<\/p>\n<li>\u4e0b\u8f7d\u5e76\u8fd0\u884c\u5bb9\u5668 (run)\u3002<\/li>\n<li>\u7ba1\u7406\u5b83\u7684\u751f\u6b7b (stop\/start\/rm)\u3002<\/li>\n<li>\u67e5\u770b\u5b83\u7684\u65e5\u8bb0 (logs)\u3002<\/li>\n<li>\u94bb\u8fdb\u5b83\u7684\u809a\u5b50\u91cc (exec)\u3002<\/li>\n<p>\u8fd9\u5df2\u7ecf\u8986\u76d6\u4e86 Docker \u65e5\u5e38\u4f7f\u7528 80% \u7684\u573a\u666f\u4e86&#xff01;<\/p>\n<hr \/>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u8981\u8fdb\u5165\u66f4\u6709\u6311\u6218\u6027\u4f46\u4e5f\u66f4\u6709\u8da3\u7684\u9636\u6bb5\u2014\u2014\u6211\u4eec\u4e0d\u518d\u7528\u522b\u4eba\u5199\u597d\u7684\u955c\u50cf&#xff0c;\u6211\u4eec\u8981\u81ea\u5df1\u5199\u4ee3\u7801&#xff0c;\u5e76\u628a\u5b83\u6253\u5305\u6210\u955c\u50cf&#xff01;<\/p>\n<p>\u51c6\u5907\u597d\u4e86\u5417&#xff1f;\u6211\u4eec\u5f00\u59cb\u5b66\u4e60 Dockerfile\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u592a\u68d2\u4e86&#xff01;\u65e2\u7136\u4f60\u5df2\u7ecf\u51c6\u5907\u597d\u4e86&#xff0c;\u6211\u4eec\u5c31\u6765\u8fd0\u884c Docker \u4e16\u754c\u7684\u201c\u5f00\u95e8\u4eea\u5f0f\u201d\u3002<br \/>\n\u5c31\u50cf\u5b66\u7f16\u7a0b\u90fd\u8981\u6253\u5370 Hello World \u4e00\u6837&#xff0c;Docker \u4e5f\u6709\u4e00\u4e2a\u4e13\u95e8\u7528\u6765\u6d4b\u8bd5\u7684\u955c\u50cf&#xff0c;\u540d\u5b57\u5c31\u53eb hello-world\u30022.1 Hello World<br \/>\n\u8bf7\u5728\u4f60\u7684\u7ec8\u7aef (Terminal\/CMD\/PowerShell) \u4e2d\u8f93\u5165\u4e0b\u9762\u8fd9\u884c\u795e\u5723\u7684\u547d\u4ee4&#xff0c;\u7136\u540e\u6309\u56de\u8f66&#xff1a;<br \/>\ndocker run hello-world\u4f60\u4f1a\u770b\u5230\u4ec0<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[27,838,763],"topic":[],"class_list":["post-61985","post","type-post","status-publish","format-standard","hentry","category-server","tag-docker","tag-eureka","tag-763"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7) - \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\/61985.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u592a\u68d2\u4e86&#xff01;\u65e2\u7136\u4f60\u5df2\u7ecf\u51c6\u5907\u597d\u4e86&#xff0c;\u6211\u4eec\u5c31\u6765\u8fd0\u884c Docker \u4e16\u754c\u7684\u201c\u5f00\u95e8\u4eea\u5f0f\u201d\u3002 \u5c31\u50cf\u5b66\u7f16\u7a0b\u90fd\u8981\u6253\u5370 Hello World \u4e00\u6837&#xff0c;Docker \u4e5f\u6709\u4e00\u4e2a\u4e13\u95e8\u7528\u6765\u6d4b\u8bd5\u7684\u955c\u50cf&#xff0c;\u540d\u5b57\u5c31\u53eb hello-world\u30022.1 Hello World \u8bf7\u5728\u4f60\u7684\u7ec8\u7aef (Terminal\/CMD\/PowerShell) \u4e2d\u8f93\u5165\u4e0b\u9762\u8fd9\u884c\u795e\u5723\u7684\u547d\u4ee4&#xff0c;\u7136\u540e\u6309\u56de\u8f66&#xff1a; docker run hello-world\u4f60\u4f1a\u770b\u5230\u4ec0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/61985.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-18T17:50:09+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/61985.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/61985.html\",\"name\":\"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-18T17:50:09+00:00\",\"dateModified\":\"2026-01-18T17:50:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/61985.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/61985.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/61985.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7)\"}]},{\"@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":"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7) - \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\/61985.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u592a\u68d2\u4e86&#xff01;\u65e2\u7136\u4f60\u5df2\u7ecf\u51c6\u5907\u597d\u4e86&#xff0c;\u6211\u4eec\u5c31\u6765\u8fd0\u884c Docker \u4e16\u754c\u7684\u201c\u5f00\u95e8\u4eea\u5f0f\u201d\u3002 \u5c31\u50cf\u5b66\u7f16\u7a0b\u90fd\u8981\u6253\u5370 Hello World \u4e00\u6837&#xff0c;Docker \u4e5f\u6709\u4e00\u4e2a\u4e13\u95e8\u7528\u6765\u6d4b\u8bd5\u7684\u955c\u50cf&#xff0c;\u540d\u5b57\u5c31\u53eb hello-world\u30022.1 Hello World \u8bf7\u5728\u4f60\u7684\u7ec8\u7aef (Terminal\/CMD\/PowerShell) \u4e2d\u8f93\u5165\u4e0b\u9762\u8fd9\u884c\u795e\u5723\u7684\u547d\u4ee4&#xff0c;\u7136\u540e\u6309\u56de\u8f66&#xff1a; docker run hello-world\u4f60\u4f1a\u770b\u5230\u4ec0","og_url":"https:\/\/www.wsisp.com\/helps\/61985.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-18T17:50:09+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/61985.html","url":"https:\/\/www.wsisp.com\/helps\/61985.html","name":"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7) - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-18T17:50:09+00:00","dateModified":"2026-01-18T17:50:09+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/61985.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/61985.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/61985.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b2c\u4e8c\u9636\u6bb5\uff1a\u73a9\u8f6c\u5bb9\u5668 (\u57fa\u7840\u547d\u4ee4\u7bc7)"}]},{"@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\/61985","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=61985"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/61985\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=61985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=61985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=61985"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=61985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}