<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>《理解Docker的多阶段镜像构建》的评论</title>
	<atom:link href="http://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/feed/" rel="self" type="application/rss+xml" />
	<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/</link>
	<description>一个程序员的心路历程</description>
	<lastBuildDate>Wed, 29 Apr 2026 22:54:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>作者：surbowl</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7522</link>
		<dc:creator>surbowl</dc:creator>
		<pubDate>Mon, 16 Nov 2020 02:56:48 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7522</guid>
		<description>条理清晰的好文章，解答了我的疑惑，顶</description>
		<content:encoded><![CDATA[<p>条理清晰的好文章，解答了我的疑惑，顶</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：cyl</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7078</link>
		<dc:creator>cyl</dc:creator>
		<pubDate>Fri, 05 Jan 2018 10:13:15 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7078</guid>
		<description>嗯，感谢感谢，我后来也看大家说这种缓存机制会有不少帮助，所以中间none镜像不应该被默认删除。</description>
		<content:encoded><![CDATA[<p>嗯，感谢感谢，我后来也看大家说这种缓存机制会有不少帮助，所以中间none镜像不应该被默认删除。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7072</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Fri, 05 Jan 2018 06:07:52 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7072</guid>
		<description>这回我终于看清了。原来你说的是 这种中间image啊，我的build也存在，当然不光是多阶段构建，普通构建也是会产生这种中间image。我之前以为您说的是一次build，出来了两个具名镜像呢。:) 这个:就是docker build的一种cache机制，为了加快后续build的速度。docker官方似乎不把这个问题当成&quot;bug&quot;。你是否发现第二次以及后续执行docker build构建时的speed非常快。如果你每次都用docker built --no-cache，那么每次都会“产生”一个或多个的中间镜像。如果看着不顺眼，新版本的docker可以使用“ docker system prune”清理。关于这类image ，这篇文章解释的不错，可以看看 https://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/</description>
		<content:encoded><![CDATA[<p>这回我终于看清了。原来你说的是 这种中间image啊，我的build也存在，当然不光是多阶段构建，普通构建也是会产生这种中间image。我之前以为您说的是一次build，出来了两个具名镜像呢。:) 这个:就是docker build的一种cache机制，为了加快后续build的速度。docker官方似乎不把这个问题当成”bug”。你是否发现第二次以及后续执行docker build构建时的speed非常快。如果你每次都用docker built &#8211;no-cache，那么每次都会“产生”一个或多个的中间镜像。如果看着不顺眼，新版本的docker可以使用“ docker system prune”清理。关于这类image ，这篇文章解释的不错，可以看看 <a href="https://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/" rel="nofollow">https://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：cyl</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7071</link>
		<dc:creator>cyl</dc:creator>
		<pubDate>Fri, 05 Jan 2018 04:37:44 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7071</guid>
		<description>不好意思才发现这个输入工具防xss直接把我说那个临时镜像的名称给过滤了，我试一下转义能不能输入进来：  

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
react-app           latest              b866c5ab8a51        4 seconds ago       17.4MB
&lt;none&gt;              &lt;none&gt;              7a5b51d49acb        5 seconds ago       302MB
nginx               alpine              e9b19873bc49        9 days ago          16.8MB
node                alpine              466bcf8bf36e        3 weeks ago         67.6MB</description>
		<content:encoded><![CDATA[<p>不好意思才发现这个输入工具防xss直接把我说那个临时镜像的名称给过滤了，我试一下转义能不能输入进来：  </p>
<p>REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE<br />
react-app           latest              b866c5ab8a51        4 seconds ago       17.4MB<br />
&lt;none&gt;              &lt;none&gt;              7a5b51d49acb        5 seconds ago       302MB<br />
nginx               alpine              e9b19873bc49        9 days ago          16.8MB<br />
node                alpine              466bcf8bf36e        3 weeks ago         67.6MB</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：cyl</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7070</link>
		<dc:creator>cyl</dc:creator>
		<pubDate>Fri, 05 Jan 2018 04:33:59 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7070</guid>
		<description>我尝试了一下ubuntu 16.04 docker 17.12ce 构建，构建完成后运行docker image ls，还是出现了临时镜像：

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
react-app           latest              b866c5ab8a51        4 seconds ago       17.4MB
                            7a5b51d49acb        5 seconds ago       302MB
nginx               alpine              e9b19873bc49        9 days ago          16.8MB
node                alpine              466bcf8bf36e        3 weeks ago         67.6MB

我和您的差异应该就只差docker版本了吧，是不是这个版本引起的问题，还是我的Dockerfile写得不对？劳驾您帮我看看我的Dockerfile : 


FROM node:alpine as builder
RUN yarn global add create-react-app &amp;&amp; cd /tmp &amp;&amp; create-react-app app &amp;&amp; cd app &amp;&amp; yarn run build

FROM nginx:alpine
COPY --from=builder /tmp/app/build /usr/share/nginx/html
EXPOSE 80
CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]</description>
		<content:encoded><![CDATA[<p>我尝试了一下ubuntu 16.04 docker 17.12ce 构建，构建完成后运行docker image ls，还是出现了临时镜像：</p>
<p>REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE<br />
react-app           latest              b866c5ab8a51        4 seconds ago       17.4MB<br />
                            7a5b51d49acb        5 seconds ago       302MB<br />
nginx               alpine              e9b19873bc49        9 days ago          16.8MB<br />
node                alpine              466bcf8bf36e        3 weeks ago         67.6MB</p>
<p>我和您的差异应该就只差docker版本了吧，是不是这个版本引起的问题，还是我的Dockerfile写得不对？劳驾您帮我看看我的Dockerfile : </p>
<p>FROM node:alpine as builder<br />
RUN yarn global add create-react-app &amp;&amp; cd /tmp &amp;&amp; create-react-app app &amp;&amp; cd app &amp;&amp; yarn run build</p>
<p>FROM nginx:alpine<br />
COPY &#8211;from=builder /tmp/app/build /usr/share/nginx/html<br />
EXPOSE 80<br />
CMD ["nginx", "-g", "daemon off;"]</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7067</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Thu, 04 Jan 2018 06:28:02 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7067</guid>
		<description>我在ubuntu 16.04上使用docker 17.09构建的镜像没有发现临时镜像啊。</description>
		<content:encoded><![CDATA[<p>我在ubuntu 16.04上使用docker 17.09构建的镜像没有发现临时镜像啊。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：cyl</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-7066</link>
		<dc:creator>cyl</dc:creator>
		<pubDate>Thu, 04 Jan 2018 04:13:22 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-7066</guid>
		<description>您好，您这样执行的时候不会出现临时镜像吗？
我执行多阶段构建之后出现了一个镜像：
CentOS  /tmp/app  docker build -t react-app:latest .                                                                                                                                                                     [15:06:46]
Sending build context to Docker daemon  370.2kB
Step 1/7 : FROM node:alpine as build-deps
 ---&gt; 466bcf8bf36e
Step 2/7 : COPY ./react-app /tmp/react-app
 ---&gt; f8dfedb48209
Step 3/7 : RUN cd /tmp/react-app &amp;&amp; yarn &amp;&amp; yarn run build
 ---&gt; Running in 75c1e9b08a1c
yarn install v1.3.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.2: The platform &quot;linux&quot; is incompatible with this module.
info &quot;fsevents@1.1.2&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.1.3: The platform &quot;linux&quot; is incompatible with this module.
info &quot;fsevents@1.1.3&quot; is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 11.63s.
yarn run v1.3.2
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  35.65 KB  build/static/js/main.35d639b7.js
  299 B     build/static/css/main.c17080f1.css

The project was built assuming it is hosted at the server root.
To override this, specify the homepage in your package.json.
For example, add this to build it for GitHub Pages:

  &quot;homepage&quot; : &quot;http://myname.github.io/myapp&quot;,

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Done in 4.99s.
Removing intermediate container 75c1e9b08a1c
 ---&gt; 548f099870d7
Step 4/7 : FROM nginx:alpine
 ---&gt; e9b19873bc49
Step 5/7 : COPY --from=build-deps /tmp/react-app/build /usr/share/nginx/html
 ---&gt; e5b5fbd38b17
Step 6/7 : EXPOSE 80
 ---&gt; Running in 1ce462466f6d
Removing intermediate container 1ce462466f6d
 ---&gt; 0bda3fdfed18
Step 7/7 : CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]
 ---&gt; Running in 2b77e31095ab
Removing intermediate container 2b77e31095ab
 ---&gt; 77848deca49d
Successfully built 77848deca49d
Successfully tagged react-app:latest
 cyl at CentOS  /tmp/app  docker image ls                                                                                                                                                                                        [15:08:01]
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
react-app           latest              77848deca49d        28 seconds ago      17.4MB
                            548f099870d7        29 seconds ago      295MB</description>
		<content:encoded><![CDATA[<p>您好，您这样执行的时候不会出现临时镜像吗？<br />
我执行多阶段构建之后出现了一个镜像：<br />
CentOS  /tmp/app  docker build -t react-app:latest .                                                                                                                                                                     [15:06:46]<br />
Sending build context to Docker daemon  370.2kB<br />
Step 1/7 : FROM node:alpine as build-deps<br />
 &#8212;&gt; 466bcf8bf36e<br />
Step 2/7 : COPY ./react-app /tmp/react-app<br />
 &#8212;&gt; f8dfedb48209<br />
Step 3/7 : RUN cd /tmp/react-app &amp;&amp; yarn &amp;&amp; yarn run build<br />
 &#8212;&gt; Running in 75c1e9b08a1c<br />
yarn install v1.3.2<br />
[1/4] Resolving packages&#8230;<br />
[2/4] Fetching packages&#8230;<br />
info fsevents@1.1.2: The platform “linux” is incompatible with this module.<br />
info “fsevents@1.1.2&#8243; is an optional dependency and failed compatibility check. Excluding it from installation.<br />
info fsevents@1.1.3: The platform “linux” is incompatible with this module.<br />
info “fsevents@1.1.3&#8243; is an optional dependency and failed compatibility check. Excluding it from installation.<br />
[3/4] Linking dependencies&#8230;<br />
[4/4] Building fresh packages&#8230;<br />
success Saved lockfile.<br />
Done in 11.63s.<br />
yarn run v1.3.2<br />
$ react-scripts build<br />
Creating an optimized production build&#8230;<br />
Compiled successfully.</p>
<p>File sizes after gzip:</p>
<p>  35.65 KB  build/static/js/main.35d639b7.js<br />
  299 B     build/static/css/main.c17080f1.css</p>
<p>The project was built assuming it is hosted at the server root.<br />
To override this, specify the homepage in your package.json.<br />
For example, add this to build it for GitHub Pages:</p>
<p>  “homepage” : “http://myname.github.io/myapp”,</p>
<p>The build folder is ready to be deployed.<br />
You may serve it with a static server:</p>
<p>  yarn global add serve<br />
  serve -s build</p>
<p>Done in 4.99s.<br />
Removing intermediate container 75c1e9b08a1c<br />
 &#8212;&gt; 548f099870d7<br />
Step 4/7 : FROM nginx:alpine<br />
 &#8212;&gt; e9b19873bc49<br />
Step 5/7 : COPY &#8211;from=build-deps /tmp/react-app/build /usr/share/nginx/html<br />
 &#8212;&gt; e5b5fbd38b17<br />
Step 6/7 : EXPOSE 80<br />
 &#8212;&gt; Running in 1ce462466f6d<br />
Removing intermediate container 1ce462466f6d<br />
 &#8212;&gt; 0bda3fdfed18<br />
Step 7/7 : CMD ["nginx", "-g", "daemon off;"]<br />
 &#8212;&gt; Running in 2b77e31095ab<br />
Removing intermediate container 2b77e31095ab<br />
 &#8212;&gt; 77848deca49d<br />
Successfully built 77848deca49d<br />
Successfully tagged react-app:latest<br />
 cyl at CentOS  /tmp/app  docker image ls                                                                                                                                                                                        [15:08:01]<br />
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE<br />
react-app           latest              77848deca49d        28 seconds ago      17.4MB<br />
                            548f099870d7        29 seconds ago      295MB</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-6972</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Tue, 14 Nov 2017 23:47:09 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-6972</guid>
		<description>不过您说的方式的确是大多数人刚入门docker时最喜欢用的镜像构建方法。这倒是提醒我了，3ks。</description>
		<content:encoded><![CDATA[<p>不过您说的方式的确是大多数人刚入门docker时最喜欢用的镜像构建方法。这倒是提醒我了，3ks。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：bigwhite</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-6971</link>
		<dc:creator>bigwhite</dc:creator>
		<pubDate>Tue, 14 Nov 2017 20:15:45 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-6971</guid>
		<description>您说的这种构建方式得到的结果是：1、打包时间更为漫长，至少首次是这样，因为在容器里搭建编译环境需要很长时间；2、打包出来的image size太过庞大。如果按照我文中的思路，您的这种方式应该是在我的第一个例子之前。</description>
		<content:encoded><![CDATA[<p>您说的这种构建方式得到的结果是：1、打包时间更为漫长，至少首次是这样，因为在容器里搭建编译环境需要很长时间；2、打包出来的image size太过庞大。如果按照我文中的思路，您的这种方式应该是在我的第一个例子之前。</p>
]]></content:encoded>
	</item>
	<item>
		<title>作者：final</title>
		<link>https://tonybai.com/2017/11/11/multi-stage-image-build-in-docker/#comment-6970</link>
		<dc:creator>final</dc:creator>
		<pubDate>Tue, 14 Nov 2017 17:25:24 +0000</pubDate>
		<guid isPermaLink="false">http://tonybai.com/?p=2459#comment-6970</guid>
		<description>在最先前的例子里，为什么不直接在myhttpserver里打包呢，这样就在一个container里打包，并且运行。

为什么要把打包的过程专门提取出来？

谢谢！</description>
		<content:encoded><![CDATA[<p>在最先前的例子里，为什么不直接在myhttpserver里打包呢，这样就在一个container里打包，并且运行。</p>
<p>为什么要把打包的过程专门提取出来？</p>
<p>谢谢！</p>
]]></content:encoded>
	</item>
</channel>
</rss>
