{"id":416,"date":"2022-05-16T14:14:55","date_gmt":"2022-05-16T06:14:55","guid":{"rendered":"http:\/\/usei.cn\/?p=416"},"modified":"2022-05-16T14:14:56","modified_gmt":"2022-05-16T06:14:56","slug":"dockerfile-%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/usei.cn\/index.php\/2022\/05\/16\/dockerfile-%e9%85%8d%e7%bd%ae\/","title":{"rendered":"Dockerfile \u914d\u7f6e"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/\/ FROM \u6307\u5b9a\u57fa\u7840\u955c\u50cf\r\nFROM nginx\r\n\u200b\r\n\/\/ RUN \u6267\u884c\u547d\u4ee4\u3002\u6bcf\u4e00\u6761 RUN \u90fd\u4f1a\u751f\u6210\u4e00\u5c42\uff0c\u4e00\u4e2a\u9700\u6c42\u5c3d\u91cf\u4f7f\u7528&amp;&amp;\uff0c\u8fd9\u6837\u5c31\u51cf\u5c11\u4e86 RUN \uff0c\u5373\u51cf\u5c11\u4e86\u5206\u5c42\r\nRUN echo '&lt;h1>Hello, Docker!&lt;\/h1>' > \/usr\/share\/nginx\/html\/index.html\r\nRUN yum update &amp;&amp; yum install -y vim python-dev\r\n\u200b\r\n\/\/ COPY: \u6e90\u8def\u5f84\u4e0b\u7684 package.json \u590d\u5236\u5230\u65b0\u4e00\u5c42\u7684\u955c\u50cf\u8def\u5f84\/usr\/src\/app\r\nCOPY package.json \/usr\/src\/app\/\r\n\u200b\r\n\/\/ WORKDIR \u6307\u5b9a\u5de5\u4f5c\u76ee\u5f55\u3002\u6307\u5b9a\u4e0b\u5c42\u5de5\u4f5c\u7684\u76ee\u5f55\u4e3a\u5bb9\u5668\u5185\u7684\/data,\u5c3d\u91cf\u4f7f\u7528\u7edd\u5bf9\u76ee\u5f55\r\nWORKDIR \/data\r\n\u200b\r\n\/\/ ADD \u6dfb\u52a0\uff0cADD\u80fd\u81ea\u52a8\u89e3\u538b\u6587\u4ef6\u3002\u4ee5\u4e0b\u4f8b\u5b50\u6700\u7ec8 hello \u5728\/data\/test \u4e0b\r\nWORKDIR \/data\r\nADD hello test\/ \r\n\u200b\r\n\/\/ COPY \u62f7\u8d1d  \u4e0eADD\u7c7b\u4f3c\uff0c\u53ea\u662f\u4e0d\u80fd\u89e3\u538b\u7f29\u6587\u4ef6\u3002\r\nWORKDIR \/DATA\r\nCOPY hello test\/\r\n\u200b\r\n\/\/ CMD \u6267\u884c\u547d\u4ee4\r\nCMD &#91;\"python\", \"app.py\"]\r\n\u200b\r\n\/\/ ENV \u8bbe\u7f6e\u73af\u5883\u53d8\u91cf \u5b9a\u4e49 NAME=Happy Feet,\u90a3\u4e48\u4e4b\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528 $NAME \u6765\u6267\u884c\u4e86 \r\nENV VERSION=1.0 DEBUG=on NAME=\"Happy Feet\" \/\/ VOLUMES\u6302\u8f7d\r\n\u200b\r\n\/\/ EXPOSE \u7aef\u53e3\u66b4\u9732 \r\nEXPOSE &lt;\u7aef\u53e31> &#91;&lt;\u7aef\u53e32>...]<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Dockerfile \u6587\u4ef6\u793a\u4f8b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ 1\u3001\u521b\u5efa Dockerfile\r\nmkdir mynginx\r\ncd mynginx\r\nvim Dockerfile\r\n\u200b\r\n\/\/ 2\u3001\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\u5e76\u4fdd\u5b58\uff1a\r\nFROM nginx\r\nRUN echo '&lt;h1>Hello, Docker!&lt;\/h1>' > \/usr\/share\/nginx\/html\/index.html\r\n\u200b\r\n\/\/ \u5728 Dockerfile \u76ee\u5f55\u4e0b\u6267\u884c\uff0c\u751f\u6210\u65b0\u7684\u81ea\u5b9a\u4e49 images\r\ndocker build -t nginx:v3 .<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Dockerfile \u6587\u4ef6\u793a\u4f8b<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":1,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":417,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions\/417"}],"wp:attachment":[{"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usei.cn\/index.php\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}