Are there better alternatives to multi-stage Docker builds for creating custom distroless images?

December 21, 2025 5 answers
Asked by velvet_hem
I'm working on reducing the size of my Flask app's Docker image using Alpine and multi-stage builds. I've been grouping RUN commands, utilizing a .dockerignore file, and copying over only what I need. However, I've found that uninstalling dependencies during the build process and managing different stages feels really fragile, especially since it tends to break with every library update. I've heard about the Minimus Image Creator, which allows users to pre-configure custom distroless images with specific packages without the need for Dockerfile rewrites. Has anyone had experience with this?

Answers

tangent to topic
Honestly, I wouldnโ€™t recommend using Alpine for Python. It can really complicate things because of the C dependencies involved. You might want to consider using Debian slim insteadโ€”it offers better compatibility without all the issues that come with Alpine.
Reply to this answer
rain_barrel_lid
Yeah, multi-stage builds shouldn't require any uninstalls. It feels like your Dockerfile might have some issues. We've been exploring Minimus for our Python apps as well, and the approach of using prebuilt distroless images seems much cleaner than dealing with Alpine's package management mess.
Reply to this answer
angle.of.reflection
It sounds like you might be going about this the wrong way. Multi-stage builds shouldn't involve any uninstalls. The concept of a builder image stage might help streamline your process. Not familiar with Flask specifics, but if you're having these issues, it may indicate a problem in how your Dockerfile is structured. Could you share it for better insights?

windowbox herbs: It sounds more like a possible oversight, as a well-crafted Dockerfile shouldn't necessitate uninstalls during builds. Maybe there's a simpler approach available.

Reply to this answer
double__check__this
You shouldnโ€™t be uninstalling anything in multi-stage builds. Just set up your stages correctly and ensure you're not bringing over unwanted layers.
Reply to this answer
sitting in the shade
Instead of uninstalling, just avoid installing unnecessary dependencies during your image creation. That way, you won't have any leftover bloat after the build stages.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions