<p>The recent posts about multi-stage docker builds produced containers that were still larger than needed. Likewise, tutorials I've found that start "FROM scratch" copy the ca-certificates.crt file from the local system. Here is a simple dockerfile which should portably produce the smallest container possible while still enabling networking: <a href="https://github.com/daved/goecho" rel="nofollow">https://github.com/daved/goecho</a></p>
<pre><code>FROM golang:1.8.1
ENV APP /app
WORKDIR /go/src${APP}/
COPY *.go .
RUN CGO_ENABLED=0 GOOS=linux; go build -a -tags netgo -
ldflags '-w' -o ${APP}
FROM scratch
ENV CERTS /etc/ssl/certs/ca-certificates.crt
COPY --from=0 ${CERTS} ${CERTS}
COPY --from=0 ${APP} ${APP}
EXPOSE 25000
ENTRYPOINT [ "/app" ]
</code></pre>
<ul>
<li>Docker 17.05 was posted to the "edge" release channel for Ubuntu a handful of hours ago. I assume that means it has also hit for other OSes.</li>
</ul>
<hr/>**评论:**<br/><br/>Oliviaruth: <pre><p>Cool! Is this availible with docker hub automated builds yet?</p></pre>daveddev: <pre><p>I think so too, thanks! I wish I could answer whether the above dockerfile is compatible with hub automated builds, but I don't use that feature. Nonetheless, my guess is that any valid dockerfile will work.</p></pre>: <pre><p>[deleted]</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传