Knowledgebase

Understanding Image Layers and Storage Drivers Print

  • 0

How images are stored on disk.

WHAT A STORAGE DRIVER DOES

Combines the read-only layers and the writable layer into one filesystem view.

WHAT THAT MECHANISM IS CALLED

A union filesystem.

WHAT HAPPENS ON WRITE

The file is copied up into the writable layer first.

WHAT THAT MEANS

Writing to a large file inside a container is slow the first time.

WHY THAT MATTERS

Databases and anything write-heavy perform poorly on the container filesystem.

WHAT TO DO

Put write-heavy data on a volume, which bypasses the union layer.

WHAT LAYER SHARING PROVIDES

Images built on the same base share those layers on disk and in transfer.

WHY THAT ARGUES FOR CONSISTENCY

Using one base image across your services saves substantial space.

WHAT COUNTS AS A LAYER

Each instruction that changes the filesystem.

WHY FEWER IS BETTER, WITHIN REASON

Each has overhead, and deleted content in earlier layers persists.

WHAT TO BALANCE AGAINST THAT

Cache efficiency, which favours separate layers for things that change at different rates.

WHAT TO CHECK WHEN IMAGES ARE UNEXPECTEDLY LARGE

The size contributed by each layer.

WHAT USUALLY EXPLAINS IT

Package caches Build artefacts Files deleted in a later layer

WHAT TO DO

Combine install and cleanup into one instruction, or use a multi-stage build.


Was this answer helpful?
Back

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


Trustpilot