{"id":159799,"date":"2020-09-22T08:52:26","date_gmt":"2020-09-22T00:52:26","guid":{"rendered":"http:\/\/4563.org\/?p=159799"},"modified":"2020-09-22T08:52:26","modified_gmt":"2020-09-22T00:52:26","slug":"docker-copmose-build-%e5%b8%a6%e5%8f%82%e6%95%b0%e7%9a%84%e9%95%9c%e5%83%8f%ef%bc%8c%e5%b9%b6%e5%90%af%e5%8a%a8%e5%ae%b9%e5%99%a8%e7%9a%84%e5%91%bd%e4%bb%a4%e6%98%af%e4%bb%80%e4%b9%88%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=159799","title":{"rendered":"docker-copmose build \u5e26\u53c2\u6570\u7684\u955c\u50cf\uff0c\u5e76\u542f\u52a8\u5bb9\u5668\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  docker-copmose build \u5e26\u53c2\u6570\u7684\u955c\u50cf\uff0c\u5e76\u542f\u52a8\u5bb9\u5668\u7684\u547d\u4ee4\u662f\u4ec0\u4e48\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : css3 <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5e38\u7528\u7684 <code>docker-compose build<\/code> \u955c\u50cf\u5e76\u542f\u52a8\u7684\u547d\u4ee4\u662f<\/p>\n<pre><code>docker-compose up -d --build <\/code><\/pre>\n<p>\u4eca\u5929 <code>build<\/code> \u4e00\u4e2a <code>Dockerfile<\/code> \u4e2d\u5e26\u53c2\u7684\u955c\u50cf\u5e76\u542f\u52a8\uff0c\u53d1\u73b0\u6b7b\u6d3b\u4e0d\u884c\uff1f\u662f\u4e0d\u652f\u6301\u5417\uff1f<\/p>\n<p><code>docker-compose.yml<\/code><\/p>\n<pre><code># docker-compose.yml version: \"3\"  services:   ei:     build:       context: .       dockerfile: Dockerfile       args:         - NODE_VERSION <\/code><\/pre>\n<p><code>Dockerfile<\/code><\/p>\n<pre><code># Dockerfile ARG NODE_VERSION  FROM node:$NODE_VERSION  RUN echo \"-&gt; $NODE_VERSION\" <\/code><\/pre>\n<p>\u5c1d\u8bd5\u4e86\u5355\u72ec <code>build<\/code> \u955c\u50cf\uff0c\u662f\u80fd <code>build<\/code> \u7684\u955c\u50cf\u7684<\/p>\n<pre><code>docker-compose build --build-arg NODE_VERSION=test ei <\/code><\/pre>\n<p>\u7136\u540e\u60f3 <code>build<\/code> \u5e76 <code>up<\/code> \u7684\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>docker-compose up -d build --build-arg NODE_VERSION=test ei <\/code><\/pre>\n<p>\u62a5\u9519(\u6211\u4f20\u7684 <code>service<\/code> \u662f <code>ei<\/code> \uff0c\u8fd9\u53d8\u6210 <code>build<\/code> \u4e86      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>8<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3440840\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : powerfulyang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8211;force-recreate \u4e3a\u4ec0\u4e48\u4e0d\u770b\u770b\u6587\u6863\u5462                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440841\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : powerfulyang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u7684\u9519                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440842\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cheng6563 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u4e0d\u662f\u7248\u672c\u95ee\u9898\uff0c3 \u6307\u7684\u662f 3.0 \u4f60\u770b 3.1 \u548c\u4e4b\u540e\u7684\u7248\u672c\u6709\u6ca1\u6709\u8fd9\u53c2\u6570                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440843\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : powerfulyang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f&#8211;build                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440844\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jakezh <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             # docker-compose.yml<br \/>version: &#8220;3&#8221;<\/p>\n<p>services:<br \/> ei:<br \/> build:<br \/> context: .<br \/> dockerfile: Dockerfile<br \/> args:<br \/> NODE_VERSION:test                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440845\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : css3 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @powerfulyang \u4e0d\u884c\u7684\uff0c\u8bd5\u8fc7\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440846\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : css3 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @jakezh \u8981 build \u7684\u65f6\u5019\u547d\u4ee4\u884c\u4f20\u503c\uff0c\u4e0d\u662f\u5199\u6b7b\u5728 cocompose                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3440847\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : css3 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @powerfulyang <br \/>\u7528<br \/>docker-compose up -d &#8211;build &#8211;build-arg NODE_VERSION=test ei<\/p>\n<p>\u76f4\u63a5\u5f39-h \u9009\u9879<br \/>Builds, (re)creates, starts, and attaches to containers for a service.<\/p>\n<p>Unless they are already running, this command also starts any linked services.<\/p>\n<p>The `docker-compose up` command aggregates the output of each container. When<br \/>the command exits, all containers are stopped. Running `docker-compose up -d`<br \/>starts the containers in the background and leaves them running.<\/p>\n<p>If there are existing containers for a service, and the service&#8217;s configuration<br \/>or image was changed after the container&#8217;s creation, `docker-compose up` picks<br \/>up the changes by stopping and recreating the containers (preserving mounted<br \/>volumes). To prevent Compose from picking up changes, use the `&#8211;no-recreate`<br \/>flag.<\/p>\n<p>If you want to force Compose to stop and recreate all containers, use the<br \/>`&#8211;force-recreate` flag.<\/p>\n<p>Usage: up [options] [&#8211;scale SERVICE=NUM&#8230;] [SERVICE&#8230;]                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>docker-copmose bu&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/159799"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=159799"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/159799\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=159799"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=159799"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=159799"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}