Size Matters

We've learned how to create images and we've even learned how to publish them. In this lesson, we will look at images in a bit more detail and discuss why the size of an image is important.

When you create an image, you want it to be as small as possible for several reasons:

  • Reduce pull and push times

  • Use a minimum amount of space in the Registry

  • Use a minimum amount of space on the machines that will run the containers

  • Use a minimum amount of space on the machine that creates the image

In order to reduce the size of an image, you need to understand that it is influenced by several factors:

  • The files included in your image

  • The base image size

  • Image layers

Ideally, you want to reduce these factors. Let’s see how.

Files Included in Your Image

Include only necessary files in your image. That may sound obvious, but it’s easy to include unwanted files.

First of all, avoid COPY instructions that are too broad. A typical example that should be avoided is:

Get hands-on with 1400+ tech skills courses.