{"id":141,"date":"2026-08-21T16:16:04","date_gmt":"2026-08-21T08:16:04","guid":{"rendered":"https:\/\/pc.wuhanioe.com\/index.php\/2026\/08\/21\/docker-%e5%ae%b9%e5%99%a8%e8%bf%9e%e4%b8%8d%e9%80%9a%e3%80%81%e7%ab%af%e5%8f%a3%e6%98%a0%e5%b0%84%e5%a4%b1%e6%95%88%ef%bc%9f%e6%8e%92%e9%94%99%e6%89%8b%e5%86%8c\/"},"modified":"2026-08-21T16:16:04","modified_gmt":"2026-08-21T08:16:04","slug":"docker-%e5%ae%b9%e5%99%a8%e8%bf%9e%e4%b8%8d%e9%80%9a%e3%80%81%e7%ab%af%e5%8f%a3%e6%98%a0%e5%b0%84%e5%a4%b1%e6%95%88%ef%bc%9f%e6%8e%92%e9%94%99%e6%89%8b%e5%86%8c","status":"publish","type":"post","link":"https:\/\/pc.wuhanioe.com\/index.php\/2026\/08\/21\/docker-%e5%ae%b9%e5%99%a8%e8%bf%9e%e4%b8%8d%e9%80%9a%e3%80%81%e7%ab%af%e5%8f%a3%e6%98%a0%e5%b0%84%e5%a4%b1%e6%95%88%ef%bc%9f%e6%8e%92%e9%94%99%e6%89%8b%e5%86%8c\/","title":{"rendered":"Docker \u5bb9\u5668\u8fde\u4e0d\u901a\u3001\u7aef\u53e3\u6620\u5c04\u5931\u6548\uff1f\u6392\u9519\u624b\u518c"},"content":{"rendered":"<p>\u300e\u5bb9\u5668\u8d77\u6765\u4e86\uff0c\u7aef\u53e3\u4e5f\u6620\u5c04\u4e86\uff0c\u6d4f\u89c8\u5668\u5374\u8fde\u4e0d\u4e0a\u300f\u2014\u2014\u8fd9\u662f Docker \u65b0\u624b\u5230\u8fdb\u9636\u90fd\u7ed5\u4e0d\u5f00\u7684\u5751\u3002Docker \u7684\u7f51\u7edc\u662f\u5206\u5c42\u7684\uff1a\u7aef\u53e3\u6620\u5c04\u3001\u5bb9\u5668\u5185\u76d1\u542c\u3001\u5bbf\u4e3b\u9632\u706b\u5899\u3001\u81ea\u5b9a\u4e49\u7f51\u7edc\u5404\u81ea\u72ec\u7acb\u3002\u4e0b\u9762\u7528\u4e00\u5957\u6392\u67e5\u987a\u5e8f\uff0c\u628a\u95ee\u9898\u9489\u5728\u5177\u4f53\u7684\u90a3\u4e00\u5c42\u3002<\/p>\n<h2>\u4e00\u3001\u5148\u6821\u9a8c\u7aef\u53e3\u6620\u5c04\u8bed\u6cd5<\/h2>\n<ol>\n<li>\u786e\u8ba4\u7528\u7684\u662f <code>-p \u5bbf\u4e3b\u7aef\u53e3:\u5bb9\u5668\u7aef\u53e3<\/code>\uff0c\u987a\u5e8f\u5199\u53cd\u4f1a\u5bfc\u81f4\u6620\u5c04\u5931\u8d25\u3002<\/li>\n<li>\u6267\u884c <code>docker ps<\/code> \u770b PORTS \u5217\u662f\u5426\u663e\u793a <code>0.0.0.0:8080-&gt;80\/tcp<\/code>\u3002<\/li>\n<li>\u82e5\u53ea\u663e\u793a\u5bb9\u5668\u7aef\u53e3\u800c\u65e0\u5bbf\u4e3b\u7ed1\u5b9a\uff0c\u8bf4\u660e <code>-p<\/code> \u6ca1\u751f\u6548\u3002<\/li>\n<\/ol>\n<h2>\u4e8c\u3001\u786e\u8ba4\u5bb9\u5668\u5185\u670d\u52a1\u771f\u7684\u5728\u76d1\u542c<\/h2>\n<ol>\n<li>\u8fdb\u5165\u5bb9\u5668\uff1a<code>docker exec -it \u5bb9\u5668 sh<\/code>\u3002<\/li>\n<li>\u6267\u884c <code>netstat -tlnp<\/code> \u6216 <code>ss -tlnp<\/code>\uff0c\u786e\u8ba4\u8fdb\u7a0b\u76d1\u542c\u5728 <code>0.0.0.0<\/code> \u800c\u975e <code>127.0.0.1<\/code>\u3002<\/li>\n<li>\u5f88\u591a\u6846\u67b6\u9ed8\u8ba4\u53ea\u7ed1 localhost\uff0c<strong>\u5916\u90e8\u81ea\u7136\u8fde\u4e0d\u8fdb<\/strong>\u3002<\/li>\n<\/ol>\n<h2>\u4e09\u3001\u6392\u67e5\u5bbf\u4e3b\u9632\u706b\u5899\u4e0e\u7aef\u53e3\u5360\u7528<\/h2>\n<ol>\n<li>\u5bbf\u4e3b\u4e0a\u6267\u884c <code>ss -tlnp | grep 8080<\/code>\uff0c\u786e\u8ba4 Docker \u4ee3\u7406\u5df2\u76d1\u542c\u3002<\/li>\n<li>Linux \u9632\u706b\u5899 <code>ufw<\/code> \u6216 <code>firewalld<\/code> \u53ef\u80fd\u62e6\u622a\uff0c\u9700\u653e\u884c\u7aef\u53e3\u3002<\/li>\n<li>\u4e91\u670d\u52a1\u5668\u8fd8\u8981\u68c0\u67e5\u5b89\u5168\u7ec4\u5165\u7ad9\u89c4\u5219\u3002<\/li>\n<\/ol>\n<h2>\u56db\u3001\u81ea\u5b9a\u4e49\u7f51\u7edc\u4e0e DNS<\/h2>\n<ol>\n<li>\u5bb9\u5668\u95f4\u901a\u4fe1\u7528<strong>\u81ea\u5b9a\u4e49 bridge \u7f51\u7edc<\/strong>\uff0c\u7528\u670d\u52a1\u540d\u4e92\u8bbf\u800c\u975e IP\u3002<\/li>\n<li>\u9ed8\u8ba4 bridge \u7f51\u6bb5\u51b2\u7a81\u65f6\uff0c\u7528 <code>docker network create --subnet<\/code> \u6307\u5b9a\u3002<\/li>\n<li>\u5bb9\u5668\u5185\u65e0\u6cd5\u89e3\u6790\u57df\u540d\uff0c\u68c0\u67e5 <code>\/etc\/resolv.conf<\/code> \u662f\u5426\u88ab\u8986\u76d6\u3002<\/li>\n<\/ol>\n<h2>\u4e94\u3001\u7528 docker network inspect \u8bca\u65ad<\/h2>\n<ol>\n<li>\u6267\u884c <code>docker network inspect \u7f51\u7edc\u540d<\/code>\uff0c\u67e5\u770b Containers \u6bb5\u662f\u5426\u5305\u542b\u76ee\u6807\u5bb9\u5668\u3002<\/li>\n<li>\u7f3a\u5931\u5219\u8bf4\u660e\u5bb9\u5668\u6ca1\u63a5\u5bf9\u7f51\u7edc\uff0c\u7528 <code>docker network connect<\/code> \u8865\u8fde\u3002<\/li>\n<\/ol>\n<h2>\u516d\u3001\u7aef\u53e3\u8303\u56f4\u4e0e host \u7f51\u7edc\u6a21\u5f0f<\/h2>\n<ol>\n<li>\u9700\u8981\u968f\u673a\u6620\u5c04\u65f6\u53ef\u7528 <code>-p 8080-<\/code> \u5f62\u5f0f\u66b4\u9732\u4e00\u6bb5\u7aef\u53e3\u8303\u56f4\u3002<\/li>\n<li>\u82e5\u6620\u5c04\u59cb\u7ec8\u4e0d\u751f\u6548\u4e14\u6392\u67e5\u65e0\u679c\uff0c\u53ef\u4e34\u65f6\u7528 <code>--network host<\/code> \u8ba9\u5bb9\u5668\u5171\u4eab\u5bbf\u4e3b\u7f51\u7edc\u6808\u9a8c\u8bc1\u3002<\/li>\n<li>host \u6a21\u5f0f\u4e0b\u4e0d\u518d\u9700\u8981 <code>-p<\/code>\uff0c\u4f46\u4f1a\u5931\u53bb\u7f51\u7edc\u9694\u79bb\uff0c\u4ec5\u7528\u4e8e\u6392\u9519\u3002<\/li>\n<\/ol>\n<p><strong>\u6280\u672f\u603b\u7ed3\uff1a<\/strong>Docker \u7f51\u7edc\u6392\u9519\u8981\u5206\u5c42\u5b9a\u4f4d\uff1a\u6620\u5c04\u8bed\u6cd5 \u2192 \u5bb9\u5668\u5185\u76d1\u542c \u2192 \u5bbf\u4e3b\u9632\u706b\u5899 \u2192 \u7f51\u7edc\u5f52\u5c5e\u3002\u6bcf\u5c42\u7528\u5bf9\u5e94\u547d\u4ee4\u9a8c\u8bc1\uff0c\u5fc5\u8981\u65f6\u7528 host \u6a21\u5f0f\u9694\u79bb\u53d8\u91cf\uff0c\u57fa\u672c\u80fd\u5728\u4e00\u4e24\u5206\u949f\u5185\u9501\u5b9a\u65ad\u70b9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u7aef\u53e3\u8bed\u6cd5\u5230\u9632\u706b\u5899\u4e0e\u81ea\u5b9a\u4e49\u7f51\u7edc\uff0c\u7cfb\u7edf\u8bca\u65ad Docker \u7f51\u7edc\u95ee\u9898\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-3"],"_links":{"self":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":0,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"wp:attachment":[{"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pc.wuhanioe.com\/index.php\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}