DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Docker Model Runner: Streamlining AI Deployment for Developers
  • A Guide to Container Runtimes
  • Gemma 3: Unlocking GenAI Potential Using Docker Model Runner
  • Docker vs Kubernetes: Which to Use and When?

Trending

  • Designing a Java Connector for Software Integrations
  • AI’s Role in Everyday Development
  • AWS to Azure Migration: A Cloudy Journey of Challenges and Triumphs
  • Agile and Quality Engineering: A Holistic Perspective
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Minideb: A Minimalist, Debian-Based Docker Image

Minideb: A Minimalist, Debian-Based Docker Image

Alpine Linux-based Docker images are small, but they can still bloat up quickly. If you're concerned about image size, search for alternatives, like Minideb.

By 
Sebastien Goasguen user avatar
Sebastien Goasguen
·
Jan. 06, 17 · Opinion
Likes (3)
Comment
Save
Tweet
Share
61.6K Views

Join the DZone community and get the full member experience.

Join For Free

When the Docker revolution started, one argument among many in favor of using containers instead of virtual machines was their size. Container images were supposed to be small.

However, several anti-patterns quickly emerged in the early days of Docker. First, most people wanted to treat containers just like VMs, hence they wanted an SSH server in them, they wanted to run multiple processes in them and they wanted their regular Linux distributions.

This quickly ballooned the size of Docker images that could be pulled from the Docker Hub. Official Ubuntu and CentOS images used to be above 600 MB. Once dependencies and application code got added, it was not rare to see several GB Docker images around.

Folks reacted rather quickly and several things happened:

  •  The official regular distro images got smaller.

  •   FROM scratch  became very popular.

  • Alpine took off.

Alpine Linux indeed allows you to create very small Docker images. It is based on busybox and muslc libc. It is rooted in embedded Linux. While very useful for testing and development, I believe that Alpine is challenging in an enterprise setting used to CentOS and Debian, where package provenance and patching is critical and where code may break unexpectedly with muslc.

But if we leave those concerns aside, is it really that small?

Comparing Official Images

If you pull the latest official images of well-known distribution you get the following sizes:

  •  `centos:7`  = 191 MB

  •  `debian:jessie`  = 194 MB

  •  `debian:jessie-slim`  = 80 MB

  •  `ubuntu:16.04`  = 129 MB

  •  `alpine:3.4`  = 4.8 MB

The first reaction is that Alpine is super small. The second reaction is that the CentOS and Debian community have reacted very well from the early days and shrank their images. The third reaction is: What is actually in those images?

"But wait," you say. "If we just compare image sizes, aren't we comparing apples and oranges?"

I will leave chasing the source of the Dockerfile(s) that makes those base images for another post. This is another rabbit hole that really scared me. But I am a Python guy, so let's see how to run Python with those images.

Adding Python

The first "surprise" is that Python is already in CentOS by default:

$ docker run --rm -it centos:7 python

Python 2.7.5 (default, Nov 6 2016, 00:28:07)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>


But it is not in the Debian or Ubuntu or Alpine images. If we look at the official Python images from the Docker Hub (which is a recommended best practice), we see that they are based on Debian (via  `FROM buildpack-deps` ). Let's pull a few and check their sizes:

  •  `python:2.7`  = 676 MB

  •  `python:2.7-slim`  = 181 MB

  •  `python:2.7-alpine`  = 72 MB

And there, big surprise, the official image is huge. The Alpine jumps to 72 MB compared to 4.5 MB when empty. And the `slim`  image is at 181 MB — really close to the 191 MB of straight up `centos:7`.

Caveat: I did look a bit deeper into the `buildpack` images. It is interesting, as the `python:2.7-slim`  is actually not based on the official `debian:jessie-slim`. If you were to use that official Debian image, you would get a 131 MB Python image, only 2x up from Alpine.

Using Minideb

Now for the last step of this post.

Let's say that you are not happy with a 191 MB official CentOS image or a 131 MB Debian-based image, solely because they are 2x or 3x bigger than the Alpine-based Python image (muslc and APK packages aside). Could we shrink a Python image?

That's where minideb, from the folks at Bitnami, comes into play. It is a minimalist, Debian-based Docker image built using debootstrap.

It sits at 50 MB, giving you standard glibc and access to standard Debian packages. It also has a convenience script to install packages and clean the cache, remove pages, etc., in order to keep images small.

Let's do a Python image with `minideb`. A simple Dockerfile will do:

FROM bitnami/minideb:jessie

RUN install_packages python


Build and run:

$ docker build -t minideb-python .

$ docker run --rm -it minideb-python python

Python 2.7.9 (default, Jun 29 2016, 13:08:31)

[GCC 4.9.2] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>>


And you get it for 79 MB, compared to the 72 MB of the official Python Image based on Alpine.

And I am sure we could do a `minicentos:7` version of it, which would shrink the official CentOS image even further.

Conclusions

This post is already too long, so let's keep it short:

  • Yes, Alpine-based images are very small, but not as small as we think (at least not with Python in them).

  • Pervasive distros like CentOS and Debian already have very small official Docker images.

  • You can't compare images based solely on size, you need to check how they are actually made (base Dockerfiles, packages installed/removed).

  • `bitnami/minideb:jessie` is a great minimalist Debian-based Docker image, which can compare in size with an Alpine image.

Docker (software)

Published at DZone with permission of Sebastien Goasguen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Docker Model Runner: Streamlining AI Deployment for Developers
  • A Guide to Container Runtimes
  • Gemma 3: Unlocking GenAI Potential Using Docker Model Runner
  • Docker vs Kubernetes: Which to Use and When?

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!