Building Small Images Print

  • 0

Why size matters and how to reduce it.

WHY SIZE MATTERS

Transfer time on every deployment Storage on every host Startup delay when pulling Attack surface

WHAT MAKES IMAGES LARGE

A full operating system as the base Build tools left in the final image Package manager caches Source code and dependencies not needed at runtime Files deleted in a later layer

WHAT A MULTI-STAGE BUILD DOES

Builds in one stage, then copies only the result into a clean final stage.

WHY THAT IS THE SINGLE BIGGEST IMPROVEMENT

Compilers, headers and development dependencies never reach the final image.

WHAT TO COPY FORWARD

The built artefact and its runtime dependencies only.

WHAT SLIM AND MINIMAL BASE IMAGES PROVIDE

Far smaller images.

WHAT THEY COST

Missing tools, which complicates debugging Occasionally, missing libraries your application needs

WHAT A DISTROLESS IMAGE IS

One containing the runtime and nothing else, not even a shell.

WHAT THAT PROVIDES

A very small attack surface.

WHAT IT COSTS

No shell to debug with.

WHAT TO USE FOR EXCLUSIONS

An ignore file, so unnecessary files never enter the build context.

WHY THAT MATTERS

The whole context is sent to the builder, including anything large or secret.

WHAT TO ALWAYS EXCLUDE

Version control directories, dependency folders, and environment files.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot