{"id":7596,"date":"2024-11-14T13:14:09","date_gmt":"2024-11-14T05:14:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7596\/"},"modified":"2024-11-14T13:14:09","modified_gmt":"2024-11-14T05:14:09","slug":"%e5%9c%a8windows-%e7%8e%af%e5%a2%83%e4%b8%8b%ef%bc%8c%e5%a6%82%e4%bd%95%e4%bf%ae%e6%94%b9-docker-%e5%ae%b9%e5%99%a8%e5%8f%82%e6%95%b0%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7596\/","title":{"rendered":"\u5728Windows \u73af\u5883\u4e0b\uff0c\u5982\u4f55\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173104764924457.jpg\" class=\"aligncenter\" title=\"\u5728Windows \u73af\u5883\u4e0b\uff0c\u5982\u4f55\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u63d2\u56fe\" alt=\"\u5728Windows \u73af\u5883\u4e0b\uff0c\u5982\u4f55\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u73af\u5883\u4e0b\u4fee\u6539  \u5bb9\u5668\u53c2\u6570\u6307\u5357<\/strong><\/p>\n<p>\u5728 windows \u73af\u5883\u4e0b\u7ba1\u7406 docker \u5bb9\u5668\u65f6\uff0c\u7528\u6237\u6709\u65f6\u9700\u8981\u4fee\u6539\u5bb9\u5668\u53c2\u6570\uff0c\u4f8b\u5982\u7aef\u53e3\u53f7\u3001\u5b57\u7b26\u7f16\u7801\u6216 binlog \u4f4d\u7f6e\u3002<\/p>\n<p><strong>\u65b9\u6cd5\u6b65\u9aa4\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u83b7\u53d6\u5bb9\u5668\u8be6\u7ec6\u4fe1\u606f\uff1a<\/strong><\/p>\n<p>\u8fd0\u884c docker inspect [\u5bb9\u5668\u540d\u79f0] \u547d\u4ee4\u4ee5\u83b7\u53d6\u5bb9\u5668\u7684\u8be6\u7ec6\u914d\u7f6e\u4fe1\u606f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u81ea\u5b9a\u4e49 dockerfile\uff1a<\/strong><\/p>\n<p>\u6839\u636e\u81ea\u5df1\u9700\u6c42\uff0c\u521b\u5efa\u5305\u542b\u4fee\u6539\u540e\u53c2\u6570\u7684\u65b0 dockerfile\u3002\u4f8b\u5982\uff0c\u8981\u4fee\u6539\u7aef\u53e3\u53f7\uff1a<\/p>\n<pre>FROM [\u57fa\u7840\u955c\u50cf]\nEXPOSE 3306<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p><strong>\u6784\u5efa\u65b0\u955c\u50cf\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 docker build [\u76ee\u5f55\u8def\u5f84] \u547d\u4ee4\u6784\u5efa\u5305\u542b\u81ea\u5b9a\u4e49\u53c2\u6570\u7684\u65b0\u955c\u50cf\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u65b0\u5bb9\u5668\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 docker run [\u65b0\u955c\u50cf\u540d\u79f0] \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e\u65b0\u955c\u50cf\u7684\u65b0\u5bb9\u5668\u3002<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u5176\u4ed6\u8c03\u6574\u9014\u5f84\uff1a<\/strong><\/p>\n<p>\u9664\u4e86\u4f7f\u7528 dockerfile \u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u9014\u5f84\u53ef\u4ee5\u8c03\u6574\u5bb9\u5668\u53c2\u6570\uff1a<\/p>\n<ul>\n<li> <strong>\u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff1a<\/strong>\u53ef\u4ee5\u5728\u542f\u52a8\u5bb9\u5668\u65f6\u4e3a\u5bb9\u5668\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/li>\n<li> <strong>\u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\uff1a<\/strong>\u53ef\u4ee5\u5c06\u914d\u7f6e\u4fe1\u606f\u5b58\u50a8\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06\u5176\u6302\u8f7d\u5230\u5bb9\u5668\u4e2d\u3002<\/li>\n<li> <strong>\u6302\u8f7d\u81ea\u5b9a\u4e49\u76ee\u5f55\uff1a<\/strong>\u53ef\u4ee5\u5c06\u81ea\u5b9a\u4e49\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u4e2d\uff0c\u5176\u4e2d\u5305\u542b\u4e0e\u5bb9\u5668\u4ea4\u4e92\u6240\u9700\u7684\u914d\u7f6e\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<p><strong>\u53c2\u8003\u6587\u6863\uff1a<\/strong><\/p>\n<ul>\n<li>[\u4f7f\u7528 dockerfile \u8c03\u6574\u5bb9\u5668\u53c2\u6570](https:\/\/docs.docker.com\/engine\/reference\/builder\/#modifier-instructions)<\/li>\n<li>[\u914d\u7f6e windows \u5bb9\u5668](https:\/\/docs.docker.com\/docker-for-windows\/conf\/)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728Windows \u73af\u5883\u4e0b\uff0c\u5982\u4f55\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u73af\u5883\u4e0b\u4fee\u6539 \u5bb9\u5668\u53c2\u6570\u6307\u5357 \u5728 windows \u73af\u5883\u4e0b\u7ba1\u7406 docker \u5bb9\u5668\u65f6\uff0c\u7528\u6237\u6709\u65f6\u9700\u8981\u4fee\u6539\u5bb9\u5668\u53c2\u6570\uff0c\u4f8b\u5982\u7aef\u53e3\u53f7\u3001\u5b57\u7b26\u7f16\u7801\u6216 binlog \u4f4d\u7f6e\u3002 \u65b9\u6cd5\u6b65\u9aa4\uff1a \u83b7\u53d6\u5bb9\u5668\u8be6\u7ec6\u4fe1\u606f\uff1a \u8fd0\u884c docker inspect [\u5bb9\u5668\u540d\u79f0] \u547d\u4ee4\u4ee5\u83b7\u53d6\u5bb9\u5668\u7684\u8be6\u7ec6\u914d\u7f6e\u4fe1\u606f\u3002 \u521b\u5efa\u81ea\u5b9a\u4e49 dockerfile\uff1a \u6839\u636e\u81ea\u5df1\u9700\u6c42\uff0c\u521b\u5efa\u5305\u542b\u4fee\u6539\u540e\u53c2\u6570\u7684\u65b0 dockerfile\u3002\u4f8b\u5982\uff0c\u8981\u4fee\u6539\u7aef\u53e3\u53f7\uff1a FROM [\u57fa\u7840\u955c\u50cf] EXPOSE 3306 \u767b\u5f55\u540e\u590d\u5236 \u6784\u5efa\u65b0\u955c\u50cf\uff1a \u4f7f\u7528 docker build [\u76ee\u5f55\u8def\u5f84] \u547d\u4ee4\u6784\u5efa\u5305\u542b\u81ea\u5b9a\u4e49\u53c2\u6570\u7684\u65b0\u955c\u50cf\u3002 \u521b\u5efa\u65b0\u5bb9\u5668\uff1a \u4f7f\u7528 docker run [\u65b0\u955c\u50cf\u540d\u79f0] \u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u57fa\u4e8e\u65b0\u955c\u50cf\u7684\u65b0\u5bb9\u5668\u3002 \u5176\u4ed6\u8c03\u6574\u9014\u5f84\uff1a \u9664\u4e86\u4f7f\u7528 dockerfile \u5916\uff0c\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u9014\u5f84\u53ef\u4ee5\u8c03\u6574\u5bb9\u5668\u53c2\u6570\uff1a \u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff1a\u53ef\u4ee5\u5728\u542f\u52a8\u5bb9\u5668\u65f6\u4e3a\u5bb9\u5668\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002 \u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\uff1a\u53ef\u4ee5\u5c06\u914d\u7f6e\u4fe1\u606f\u5b58\u50a8\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06\u5176\u6302\u8f7d\u5230\u5bb9\u5668\u4e2d\u3002 \u6302\u8f7d\u81ea\u5b9a\u4e49\u76ee\u5f55\uff1a\u53ef\u4ee5\u5c06\u81ea\u5b9a\u4e49\u76ee\u5f55\u6302\u8f7d\u5230\u5bb9\u5668\u4e2d\uff0c\u5176\u4e2d\u5305\u542b\u4e0e\u5bb9\u5668\u4ea4\u4e92\u6240\u9700\u7684\u914d\u7f6e\u4fe1\u606f\u3002 \u53c2\u8003\u6587\u6863\uff1a [\u4f7f\u7528 dockerfile \u8c03\u6574\u5bb9\u5668\u53c2\u6570](https:\/\/docs.docker.com\/engine\/reference\/builder\/#modifier-instructions) [\u914d\u7f6e windows \u5bb9\u5668](https:\/\/docs.docker.com\/docker-for-windows\/conf\/) \u4ee5\u4e0a\u5c31\u662f\u5728Windows \u73af\u5883\u4e0b\uff0c\u5982\u4f55\u4fee\u6539 Docker \u5bb9\u5668\u53c2\u6570\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7596","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7596"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7596\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}