Docker Image Size – Does It Matter?

Does Docker image size matter? The answer I usually hear is “yes”. The logical question that follows is “why?”.

I’ve heard the following two answers too often for my liking:

  • A smaller image takes less disk space.
  • A large image is difficult to upload. It takes a long time.

Although both these statements sound like they make sense, neither is generally true.

There are some other legitimate reasons why it’s desirable to have smaller Docker images, like reducing the attack surface. But in this article, I want to address the urban legends mentioned above.

Imported from Disqus

Avatar

Kyle C. Quest2 years ago

Good and valid points about the shared base image use and how it can reduce the storage and transfer time/costs. These aspects are usually not discussed because the math becomes a bit more complicated and environment specific :slight_smile: However, some of the assumptions in the post are not always true or, at least, not to the same degree. For example, the size of the ‘frequently changing layers’ is not always ideal because not everybody is a Dockerfile ninja. Not all environments use the same base image too. Companies usually end up with a set of different base images for many different reasons (different language stacks, different framework versions, different base image preferences, external dependencies, etc). Few environments have only one base image. 3rd party Docker images also make things more fun :slight_smile:

DockerSlim tries to give you smaller images ‘for free’ where you don’t have to worry about being a Dockerfile ninja and you don’t have to use a small Linux distro that may break your application.