{"id":5314,"date":"2023-05-16T15:51:10","date_gmt":"2023-05-16T07:51:10","guid":{"rendered":"https:\/\/app.applebyme.cn\/cloud\/?p=5314"},"modified":"2023-05-16T15:51:10","modified_gmt":"2023-05-16T07:51:10","slug":"docker%e5%b0%81%e8%a3%85exe%e6%93%8d%e4%bd%9c%e6%95%99%e7%a8%8b%e7%a4%ba%e4%be%8b","status":"publish","type":"post","link":"https:\/\/app.applebyme.cn\/cloud\/exekaifa\/5314.html","title":{"rendered":"docker\u5c01\u88c5exe\u64cd\u4f5c\u6559\u7a0b\u793a\u4f8b"},"content":{"rendered":"<p>Docker \u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u5bb9\u5668\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u5e94\u7528\u7a0b\u5e8f\u548c\u4f9d\u8d56\u9879\u6253\u5305\u5230\u4e00\u4e2a\u53ef\u79fb\u690d\u7684\u5bb9\u5668\u4e2d\uff0c\u4ee5\u4fbf\u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002\u5728 Docker \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 Dockerfile \u6765\u5b9a\u4e49\u4e00\u4e2a\u955c\u50cf\uff0c\u7136\u540e\u4f7f\u7528 docker build <a href=\"https:\/\/exe.yimenapp.com\/tool-3690.html\">cab\u6253\u5305\u5de5\u5177<\/a>\u547d\u4ee4\u6784\u5efa\u51fa\u8fd9\u4e2a\u955c\u50cf\u3002\u5728\u6784\u5efa\u955c\u50cf\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 COPY \u547d\u4ee4\u5c06\u672c\u5730\u6587\u4ef6\u590d\u5236\u5230\u955c\u50cf\u4e2d\uff0c\u5305\u62ec exe \u6587\u4ef6\u3002<\/p>\n<p>\u5c06 exe \u6587\u4ef6\u5c01\u88c5\u5230 Docker \u955c\u50cf\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u6211\u4eec\u7684\u5e94\u7528\u7a0b\u5e8f\u66f4\u52a0\u4fbf\u643a\u548c\u53ef\u79fb\u690d\u3002\u4f7f\u7528 Docker \u955c\u50cf\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u548c\u73af\u5883\u4e2d\u8fd0\u884c\u5e94\u7528\u7a0b\u5e8f\uff0c\u800c\u65e0\u9700\u62c5\u5fc3\u4f9d\u8d56\u9879\u548c\u914d\u7f6e\u7684\u95ee\u9898\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u5c06 exe \u6587\u4ef6\u5c01\u88c5\u5230 Docker \u955c\u50cf\u4e2d\u7684\u6b65\u9aa4\uff1a<\/p>\n<p>1.<a href=\"https:\/\/exe.yimenapp.com\/tool-2675.html\">\u7535\u8111\u4e0a\u7684\u8f6f\u4ef6\u7528\u4ec0\u4e48\u8bed\u8a00\u5f00\u53d1\u7684<\/a> \u7f16\u5199 Dockerfile<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b Dockerfile \u6765\u6784\u5efa\u4e00\u4e2a\u5305\u542b exe \u6587\u4ef6\u7684\u955c\u50cf\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>FROM microsoft\/dotnet:2.2-runtime<\/p>\n<p>WORKDIR \/app<\/p>\n<p>COPY MyApp.exe .<\/p>\n<p>ENTRYPOINT [&#8220;dotnet&#8221;, &#8220;MyApp.exe&#8221;]<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a Dockerfile \u4f7f\u7528\u4e86 .NET Core 2.2 \u8fd0\u884c\u65f6\u4f5c\u4e3a\u57fa\u7840\u955c\u50cf\uff0c\u5e76\u5c06\u5de5\u4f5c\u76ee\u5f55\u8bbe\u7f6e\u4e3a \/app\u3002\u7136\u540e\u4f7f\u7528 COPY \u547d\u4ee4\u5c06 MyApp.exe \u6587\u4ef6\u590d\u5236\u5230 \/app \u76ee\u5f55\u4e2d\u3002\u6700\u540e\uff0c\u4f7f\u7528 ENTRYPOINT \u6307\u4ee4\u6765\u6307\u5b9a\u5e94\u7528\u7a0b\u5e8f\u7684\u542f\u52a8\u547d\u4ee4\u3002<\/p>\n<p>2. \u6784\u5efa\u955c\u50cf<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u6784\u5efa\u955c\u50cf\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>docker build -t myapp .<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f1a\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u67e5\u627e Dockerfile \u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u5b83\u6765\u6784\u5efa\u4e00\u4e2a\u540d\u4e3a myapp \u7684\u955c\u50cf\u3002<\/p>\n<p>3. \u8fd0\u884c\u5bb9\u5668<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884c\u5bb9\u5668\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>docker run -d myapp<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u4f1a\u5728\u540e\u53f0\u8fd0\u884c myapp \u955c\u50cf\uff0c\u5e76\u5c06\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u8d77\u6765\u3002\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u9700\u8981\u7ed1\u5b9a\u7aef\u53e3\uff0c\u53ef\u4ee5\u4f7f\u7528 -p \u53c2\u6570\u6765\u6307\u5b9a\u7aef\u53e3\u6620\u5c04\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5c06 exe \u6587\u4ef6\u5c01\u88c5\u5230 Docker \u955c\u50cf\u4e2d\uff0c\u5e76\u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u5b83\u3002\u8fd9\u6837\u7684\u597d\u5904\u662f\uff0c\u6211\u4eec\u53ef\u4ee5\u4fdd\u8bc1\u5e94\u7528\u7a0b\u5e8f\u7684\u4f9d\u8d56\u9879\u548c\u914d\u7f6e\u662f\u4e00\u81f4\u7684\uff0c\u4ece\u800c\u907f\u514d\u4e86\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u51fa\u73b0\u7684\u95ee\u9898\u3002<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/17\/17\/25379295060.jpg\" \/><\/figure><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker \u662f\u4e00\u79cd\u8f7b\u91cf\u7ea7\u5bb9\u5668\u6280\u672f\uff0c\u53ef\u4ee5\u5c06\u5e94\u7528\u7a0b\u5e8f\u548c\u4f9d\u8d56\u9879\u6253\u5305\u5230\u4e00\u4e2a\u53ef\u79fb\u690d\u7684\u5bb9\u5668\u4e2d\uff0c\u4ee5\u4fbf\u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u8fd0\u884c\u3002\u5728 Docker \u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 Dockerfile \u6765\u5b9a\u4e49\u4e00\u4e2a\u955c\u50cf\uff0c\u7136\u540e\u4f7f\u7528 doc<\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[1775,3563,7520,7521,7519],"class_list":["post-5314","post","type-post","status-publish","format-standard","hentry","category-exekaifa","tag-1775","tag-3563","tag-7520","tag-exe","tag-7519"],"_links":{"self":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/5314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/comments?post=5314"}],"version-history":[{"count":0,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/posts\/5314\/revisions"}],"wp:attachment":[{"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/media?parent=5314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/categories?post=5314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/app.applebyme.cn\/cloud\/wp-json\/wp\/v2\/tags?post=5314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}