{"id":38,"date":"2024-06-05T19:35:26","date_gmt":"2024-06-05T11:35:26","guid":{"rendered":"https:\/\/blog.jackyzou.tech\/?p=38"},"modified":"2025-12-27T13:23:44","modified_gmt":"2025-12-27T05:23:44","slug":"38","status":"publish","type":"post","link":"https:\/\/blog.jackyzou.tech\/index.php\/2024\/06\/05\/38\/","title":{"rendered":"Docker\u57fa\u7840\u77e5\u8bc6"},"content":{"rendered":"<h2><strong>\u8de8\u5e73\u53f0<\/strong><\/h2>\n<p>\u5feb\u901f\u8fd0\u884c\u5e94\u7528run\u3001\u5feb\u901f\u6784\u5efa\u5e94\u7528build\u3001\u5feb\u901f\u5206\u4eab\u5e94\u7528share<\/p>\n<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/blog.jackyzou.tech\/wp-content\/uploads\/2025\/12\/image-20240605185404659.png\" \/ alt=\"Docker\u57fa\u7840\u77e5\u8bc6 - \u7b2c1\u5f20\u56fe\u7247\" title=\"Docker\u57fa\u7840\u77e5\u8bc6 - \u7b2c1\u5f20\u56fe\u7247 | \u5143\u6b4c\u7684\u535a\u5ba2\" ><\/p>\n<h2>docker\u5e38\u7528\u547d\u4ee4<\/h2>\n<pre><code class=\"language-shell\">#\u67e5\u770b\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668\ndocker ps\n#\u67e5\u770b\u6240\u6709\u5bb9\u5668\ndocker ps -a\n#\u641c\u7d22\u955c\u50cf\ndocker search nginx\n#\u4e0b\u8f7d\u955c\u50cf\ndocker pull nginx\n#\u4e0b\u8f7d\u6307\u5b9a\u7248\u672c\u955c\u50cf\ndocker pull nginx:1.26.0\n#\u67e5\u770b\u6240\u6709\u955c\u50cf\ndocker images\n#\u5220\u9664\u6307\u5b9aid\u7684\u955c\u50cf\ndocker rmi e784f4560448\n\n#\u8fd0\u884c\u4e00\u4e2a\u65b0\u5bb9\u5668\ndocker run nginx\n#\u505c\u6b62\u5bb9\u5668\ndocker stop keen_blackwell\n#\u542f\u52a8\u5bb9\u5668\ndocker start 592\n#\u91cd\u542f\u5bb9\u5668\ndocker restart 592\n#\u67e5\u770b\u5bb9\u5668\u8d44\u6e90\u5360\u7528\u60c5\u51b5\ndocker stats 592\n#\u67e5\u770b\u5bb9\u5668\u65e5\u5fd7\ndocker logs 592\n#\u5220\u9664\u6307\u5b9a\u5bb9\u5668\ndocker rm 592\n#\u5f3a\u5236\u5220\u9664\u6307\u5b9a\u5bb9\u5668\ndocker rm -f 592\n# \u540e\u53f0\u542f\u52a8\u5bb9\u5668\ndocker run -d --name mynginx nginx\n# \u540e\u53f0\u542f\u52a8\u5e76\u66b4\u9732\u7aef\u53e3\ndocker run -d --name mynginx -p 80:80 nginx\n# \u8fdb\u5165\u5bb9\u5668\u5185\u90e8\ndocker exec -it mynginx \/bin\/bash\n\n# \u63d0\u4ea4\u5bb9\u5668\u53d8\u5316\u6253\u6210\u4e00\u4e2a\u65b0\u7684\u955c\u50cf\ndocker commit -m &quot;update index.html&quot; mynginx mynginx:v1.0\n# \u4fdd\u5b58\u955c\u50cf\u4e3a\u6307\u5b9a\u6587\u4ef6\ndocker save -o mynginx.tar mynginx:v1.0\n# \u5220\u9664\u591a\u4e2a\u955c\u50cf\ndocker rmi bde7d154a67f 94543a6c1aef e784f4560448\n# \u52a0\u8f7d\u955c\u50cf\ndocker load -i mynginx.tar \n\n# \u767b\u5f55 docker hub\ndocker login\n# \u91cd\u65b0\u7ed9\u955c\u50cf\u6253\u6807\u7b7e\ndocker tag mynginx:v1.0 leifengyang\/mynginx:v1.0\n# \u63a8\u9001\u955c\u50cf\ndocker push leifengyang\/mynginx:v1.0<\/code><\/pre>\n<h2>\u5b58\u50a8<\/h2>\n<p>\u4e24\u79cd\u65b9\u5f0f\uff0c\u6ce8\u610f\u533a\u5206\uff1a<\/p>\n<ul>\n<li>\u76ee\u5f55\u6302\u8f7d\uff1a <code>-v \/app\/nghtml:\/usr\/share\/nginx\/html<\/code><\/li>\n<li>\u5377\u6620\u5c04\uff1a<code>-v ngconf:\/etc\/nginx<\/code><\/li>\n<\/ul>\n<pre><code class=\"language-shell\">docker run -d -p 99:80 \\\n-v \/app\/nghtml:\/usr\/share\/nginx\/html \\\n-v ngconf:\/etc\/nginx \\\n--name app03 \\\nnginx<\/code><\/pre>\n<h2>Docker\u7684\u4e09\u79cd\u7f51\u7edc\u6a21\u5f0f<\/h2>\n<p>Docker\u652f\u6301\u4e09\u79cd\u7f51\u7edc\u6a21\u5f0f\uff1aHost\u6a21\u5f0f\u3001Bridge\u6a21\u5f0f\u548cNone\u6a21\u5f0f\u3002\u5b83\u4eec\u5404\u81ea\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u573a\u666f\u548c\u9700\u6c42\uff1a<\/p>\n<p>Host\u6a21\u5f0f\uff1a\u5c06\u5bb9\u5668\u52a0\u5165\u5230\u4e3b\u673a\u7684\u7f51\u7edc\u6808\u4e2d\uff0c\u4f7f\u5bb9\u5668\u76f4\u63a5\u4f7f\u7528\u4e3b\u673a\u7684\u7f51\u7edc\u63a5\u53e3\u548cIP\u5730\u5740\u3002Host\u6a21\u5f0f\u9002\u7528\u4e8e\u9700\u8981\u5bb9\u5668\u4e0e\u4e3b\u673a\u5171\u4eab\u7f51\u7edc\u8d44\u6e90\u6216\u8005\u5bb9\u5668\u9700\u8981\u5feb\u901f\u8bbf\u95ee\u4e3b\u673a\u7f51\u7edc\u670d\u52a1\u7684\u573a\u666f\u3002<\/p>\n<p>Bridge\u6a21\u5f0f\uff1a\u4f7f\u7528\u4e00\u4e2aDocker\u5185\u7f6e\u7684\u7f51\u6865Docker0\u4f5c\u4e3a\u5bb9\u5668\u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u5bb9\u5668\u4e4b\u95f4\u4e92\u76f8\u9694\u79bb\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7\u7f51\u7edc\u4e92\u76f8\u901a\u4fe1\u3002Bridge\u6a21\u5f0f\u9002\u7528\u4e8e\u6784\u5efa\u590d\u6742\u7684\u591a\u5bb9\u5668\u5e94\u7528\u7a0b\u5e8f\uff0c\u5bb9\u5668\u4e4b\u95f4\u9700\u8981\u4e92\u76f8\u901a\u4fe1\uff0c\u540c\u65f6\u9700\u8981\u4fdd\u6301\u7f51\u7edc\u9694\u79bb\u7684\u573a\u666f\u3002<\/p>\n<p>None\u6a21\u5f0f\uff1a\u5bb9\u5668\u6ca1\u6709\u4efb\u4f55\u7f51\u7edc\u63a5\u53e3\uff0c\u65e0\u6cd5\u4e0e\u5916\u90e8\u7f51\u7edc\u6216\u5176\u4ed6\u5bb9\u5668\u901a\u4fe1\u3002\u9002\u7528\u4e8e\u9700\u8981\u5b8c\u5168\u9694\u79bb\u7684\u573a\u666f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8de8\u5e73\u53f0 \u5feb\u901f\u8fd0\u884c\u5e94\u7528run\u3001\u5feb\u901f\u6784\u5efa\u5e94\u7528build\u3001\u5feb\u901f\u5206\u4eab\u5e94\u7528share docker\u5e38\u7528\u547d\u4ee4 #\u67e5\u770b\u8fd0\u884c\u4e2d\u7684\u5bb9\u5668 docker ps #\u67e5\u770b\u6240\u6709\u5bb9\u5668 docker ps -a #\u641c\u7d22\u955c\u50cf docker search nginx #\u4e0b\u8f7d\u955c\u50cf docker pull nginx #\u4e0b\u8f7d\u6307\u5b9a\u7248\u672c\u955c\u50cf docker pull nginx:1.26.0 #\u67e5\u770b\u6240\u6709\u955c\u50cf docker images #\u5220\u9664\u6307\u5b9aid\u7684\u955c\u50cf docker rmi e784f4560448 #\u8fd0\u884c\u4e00\u4e2a\u65b0\u5bb9\u5668 docker run nginx #\u505c\u6b62\u5bb9\u5668 docker stop keen_blackwell #\u542f\u52a8\u5bb9\u5668 doc&#8230;&#8230;<span class=\"read-more\"> <a href=\"https:\/\/blog.jackyzou.tech\/index.php\/2024\/06\/05\/38\/\"><\/p>\n<p>\u7ee7\u7eed\u9605\u8bfb&raquo;&raquo;&raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[5],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-4","tag-docker"],"_links":{"self":[{"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":0,"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jackyzou.tech\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}