What's the Right Balance for Minimal Production Containers?
Asked by
Bungle
I'm trying to figure out how to create minimal images for our production containers. We've been stripping down base images, but the developers keep running into issues where certain utilities are missing, which breaks our CI/CD workflows. Every time we remove a dependency, it seems to lead to subtle runtime bugs. How do you determine what's essential versus optional when building these minimal images?
Answers
It's definitely challenging to create super minimal images. An alternative is to use vulnerability-free container images or explore distroless options. They can be cleaner or easier to manage with a package manager, so it's worth checking them out.
Reply to this answer
CI/CD shouldn't really be slowed down by the size of your final images. When deciding what's essential, focus on what's absolutely necessary to run your service smoothly. Everything else can be considered optional. But it's a balanceโthink about storage and network costs, startup times for new pods, and how much work it takes to keep images slim. It really depends on the stack you're using as well; for instance, Go apps tend to run really small.
Reply to this answer
Keep it simple: essential items are what your app needs to run; optional tools are the rest. For production, donโt install any unnecessary packages. Consider using multi-stage builds where you can keep development tools separate from production images. I'm curious about the specific sizing issues that led to your question.
Reply to this answer
You can strip away anything unnecessary when creating minimal images. With the debug container support in Kubernetes, you typically donโt need to include a lot of tools directly in your images. Instead of using these images for CI/CD, consider creating specific build images with the necessary tools included.
Reply to this answer
Iโve found that rushing to make the smallest image isnโt always worth it. Start with the dependencies you know your app needs and run your CI/CD scripts locally against your candidate image. Take note whenever something fails due to a missing tool and discuss whether itโs necessary for production or just for builds. Avoid including build tools in production images, but having basic utilities handy can really help during live debug sessions.
Reply to this answer
When we switched to distroless images, our ops team struggled because they couldnโt do anything. So, we ended up creating debug images with shells and other tools to help during development and quickly resolve issues. Having some debugging tools can be useful!
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions