2 ms·
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
by yjftsjthsd-h 7y 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'd not seen before (busybox:glibc). I would be curious to see how these base images stack up against Google's "distroless" base images (https://github.com/GoogleContainerTools/distroless https://github.com/GoogleContainerTools/distroless). I also appreciate that they call out Alpine'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'm quite fond of Alpine, but I don't bother when using binaries that expect glibc.)
- yegle 7y agoOne important thing missing from BusyBox:glibc is the SSL certificates that's almost always needed if you are writing things like crawler etc. As for Alpine, at least for packaging Python code, avoid as much as possible. It cannot reuse manylinux packages on PyPI and have to recompile C modules.
- gopalv 7y agoWith Alpine, the size advantages of musl sometimes come with hidden overheads as well. Musl's malloc() seems to be a fair bit slower than glibc's when you start to throw in more threads at it (fragments faster?). And then if you try to replace that with jemalloc, you'll quickly find out that jemalloc does not actually get used. At some level, the difference between a 1Mb docker image and a 9Mb one isn't that significant (& I asked for some things like strace, ping and nslookup to be in it, because it gets impossible to debug the container when it obviously caches a DNS record or at least, looks like it is doing that).
- mxschumacher 7y agoand as a result: plenty of breaking builds https://github.com/pyca/cryptography/issues/4264 https://github.com/pyca/cryptography/issues/4264
- fiddlerwoaroof 7y agoOne thing they don't talk about is using non-docker tools to build images. e.g. nix: http://lethalman.blogspot.com/2016/04/cheap-docker-images-with-nix_15.html http://lethalman.blogspot.com/2016/04/cheap-docker-images-wi... or jib: https://github.com/GoogleContainerTools/jib https://github.com/GoogleContainerTools/jib These may not fit every use case, but they can minimize the size of the image by making really precisely defined containers.
- donmcronald 7y agoIt’s worth looking at an overview of how Jib works because the general strategy is very good IMO. https://phauer.com/2019/no-fat-jar-in-docker-image/ https://phauer.com/2019/no-fat-jar-in-docker-image/
- DyslexicAtheist 7y agobeen using docker-slim[1] for a couple years and am really happy with it. Also I build everything from source and try to avoid glibc wherever I can, use hardened malloc and -D_FORTIFY_SOURCE=2 everything. also use static linking wherever I can and try to --disable-foo with configure if I can get away with it. Using a minimalistic approach that restricts everything (down to a syscall whitelist) sounds like it's high maintenence but when done in combination with a catalog of what runs in these containers and some plumbing to poll upstream for repo updates allows me to ignore a lot of what affects most people wrt security. As a bonus I learn about it quickly if upstream introduces a major change and I'm forced to study the source and get to decide if they were "out of their mind again" with these changes. Keeps me abreast of how my platform behaves and when it doesn't as it should (it's kind of a forward investment for efficient root cause analysis that beats "have you tried turning it off and on again") Docker imo doesn't deserve the hype. Most of the flaws I deal with in my setup are due to docker instability (often in docker swarm) ... it's the next thing I actually want to replace because it's just overhyped "static linking for Millennials". [1] https://github.com/docker-slim/docker-slim https://github.com/docker-slim/docker-slim
- Jonnax 7y agoDocker Swarm has been pretty much deprecated. When Mirantis bought it, they said they'll support for 2 years but Kubernetes is their focus.
- DyslexicAtheist 7y agothanks, a good reason to ditch it then.