liveBook · Manning

Image size

As explained in Build Financial Software with Generative AI (From Scratch)

Image size is the amount of storage space required by a container image.

Image size is the storage space required by a container image. Monitoring it helps reduce the space used by a Docker application and guides choices between standard, slim, and Alpine images. section 3.6.2

Reduce image size by:

  • Inspecting current images with docker image ls. section 3.6.2
  • Choosing slim images when the Dockerfile depends on Debian tools such as apt-get. section 3.6.2
  • Using Alpine images when required software supports musl libc, BusyBox, and apk, then testing compatibility. section 3.6.2
  • Keeping Dockerfile layers minimal and cleaning temporary files in the same layer that creates them. section 3.6.3

Comparing container image sizes

A Docker application starts with a 1.09 GB API image, a 417 MB Postgres image, and a 187 MB web image. Switching Postgres to Alpine reduces it to 239 MB, switching the web image reduces it to 42.6 MB, and replacing the API base image with slim reduces it to about 557 MB. section 3.6.2

dockercompose7-web   latest    9d0257a0f9b0   About an hour ago   187MB
postgres             latest    e872544a957a   About an hour ago   417MB
dockercompose7-api   latest    5a2bb8fc1b02   24 hours ago        1.09GB
cloudbeaver          latest    9b672f480fc7   2 weeks ago         250MB

Use the image listing to compare container sizes before changing base images or Dockerfile instructions. section 3.6.2

How Build Financial Software with Generative AI (From Scratch) covers it

How deep it goes
Compares measured image reductions, base-image trade-offs, layers, cleanup, and caching without detailing complete Alpine migration steps.
Examples
Uses docker image ls, API, web, and Postgres images, Alpine and slim tags, Docker Scout analysis, and Dockerfile cleanup.
What you can do after
Operate Docker images more efficiently by measuring sizes and selecting compatible base images and layer arrangements.
How it connects
Connects image size with Dockerfiles, Docker image layers, Alpine Linux, slim images, and Docker build caching.

Also explained in

Compare how 2 books explain image size →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Financial Software with Generative AI (From Scratch). The section links point to the parts of the book it draws on.