TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Reducing Docker Image Size

176 pointsby aberohamover 5 years ago

7 comments

yjftsjthsd-hover 5 years ago
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 未加载
paxysover 5 years ago
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 未加载
thinkingemoteover 5 years ago
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 未加载
danielhlockardover 5 years ago
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 未加载
avipover 5 years ago
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.
snicker7about 5 years ago
Are containers really the best abstraction for providing application isolation &#x2F; portability? What about snaps&#x2F;nix&#x2F;guix instead?
评论 #22379438 未加载
jiofihabout 5 years ago
Strange advice to not use Alpine, but then recommends an empty image or busybox...
评论 #22379419 未加载