TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Reducing Docker Image Size

176 点作者 aberoham超过 5 年前

7 条评论

yjftsjthsd-h超过 5 年前
Seems to be a pretty decent overview; covers the usual suspects (multi-stage builds, FROM scratch, non-scratch minmal images, ldd to check libraries), with some nice bits that I&#x27;d not seen before (busybox:glibc). I would be curious to see how these base images stack up against Google&#x27;s &quot;distroless&quot; base images (<a href="https:&#x2F;&#x2F;github.com&#x2F;GoogleContainerTools&#x2F;distroless" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;GoogleContainerTools&#x2F;distroless</a>). I also appreciate that they call out Alpine&#x27;s compatibility issues (on account of musl) but still leave it as a thing that can be good if you use it right. (Personally I&#x27;m quite fond of Alpine, but I don&#x27;t bother when using binaries that expect glibc.)
评论 #22373063 未加载
评论 #22372185 未加载
评论 #22373771 未加载
paxys超过 5 年前
While such articles are usually helpful, I&#x27;d caution that making individual image sizes as small as possible shouldn&#x27;t really be your goal.<p>As a simple example - if you have 100 unique images in your system, having an image size of 1 GB each where 99% of it is derived from a common layer is going to be a lot smaller overall than &quot;optimizing&quot; the size down to 100 MB each but taking away the base layers.
评论 #22370844 未加载
评论 #22375220 未加载
thinkingemote超过 5 年前
Why is image size important? Should we instead optimise for speed of build?<p>If storage is cheap. And CPU costs Co2 does it make sense to spend longer time and more energy to save disk space?
评论 #22370761 未加载
评论 #22370735 未加载
评论 #22370887 未加载
评论 #22371226 未加载
评论 #22373976 未加载
danielhlockard超过 5 年前
It&#x27;s worth noting that golang builds can be smaller than that with `GOOS=linux go build -ldflags=&quot;-s -w&quot; .` (assuming a build on macos for linux.) From there I usually run `upx --ultra-brute -9 program` before dropping it into a `scratch` docker container (plus whatever other deps it needs).
评论 #22371849 未加载
avip超过 5 年前
This is indeed a good overview.<p>It would have been <i>a great</i> overview had it started with briefing readers about why (or when) image size should bother us at all.
snicker7超过 5 年前
Are containers really the best abstraction for providing application isolation &#x2F; portability? What about snaps&#x2F;nix&#x2F;guix instead?
评论 #22379438 未加载
jiofih超过 5 年前
Strange advice to not use Alpine, but then recommends an empty image or busybox...
评论 #22379419 未加载