Docker Images : Reducing Image Size

When getting started with containers, it’s pretty easy to be shocked by the size of the images that we build. We’re going to review a number of techniques to reduce image size, without sacrificing developers’ and ops’ convenience. In this first part, we will talk about multi-stage builds, because that’s where anyone should start if they want to reduce the size of their images. We will also explain the differences between static and dynamic linking, as well as why we should care about that. This will be the occasion to introduce Alpine.

https://www.ardanlabs.com/blog/2020/02/docker-images-part1-reducing-image-size.html

7 thoughts on “Docker Images : Reducing Image Size”

  1. Wow, I went in expecting to slam this article as Alpine/small image hype. But, it is actually an excellent run down of the issues in play!

    Reply
  2. Good articles. I’d have added at the beginning the basic explanation of why removing a big file as a dockerfile step doesn’t make the image smaller (hence we use build images to create run images)

    Reply
  3. I think that the last part of part 1 is missing the dockerfile, specifically the part with BusyBox:glibc
    Excellent articles though.

    Reply
  4. Only thing to watch out for is that stuff can be kinda hardcoded to glibc sometimes and Alpine uses musl libc. For simple stuff Alpine is great though.

    Reply
  5. This is the second time I’ve said this in a week… I struggled with this myself recently and couldn’t find a definitive guide to help me through it, so brute forced my way through by trial and error, turning a 2.4 GB image in to a 80MB image that contained just the GoLang executable and assets (ca-root and tz-data)

    Thank you for writing this, you will have saved future generations from the horror I went through.

    Reply

Leave a Comment