Base image

Also known as: parent image

On this page 7

A base image is the container image named in the FROM instruction of a Dockerfile, the foundation on which every later build step adds its own layers. In containers and cloud-native delivery, it supplies the operating system userland, package manager, shared libraries and often a language runtime that the application expects to find at run time. The term parent image is used as a synonym, although some documentation reserves base image for an image built from the empty scratch starting point.

Choosing a base image is one of the most consequential decisions in a container build. It determines image size, attack surface, patch cadence, compatibility with native libraries and how quickly vulnerabilities can be fixed across every service that inherits from it.

How a base image becomes the bottom of the layer stack

A base image works as a read-only stack of image layers that the builder pulls and then extends. When a build engine such as BuildKit or Buildah processes FROM debian:bookworm-slim, it resolves the tag to a manifest digest, downloads the referenced layers from a container registry and uses their combined filesystem as the starting state for the next instruction.

Each later instruction, such as RUN, COPY or ADD, produces a new layer containing only the filesystem changes. At run time, the container runtime mounts all layers through a union or overlay filesystem, so the base layers are shared on disk between every container and image that references the same digest. That sharing is why a common base across many services saves storage and speeds up pulls.

The base image also contributes image configuration, not only files. The following table shows which settings are inherited and whether a child Dockerfile can override them.

SettingInherited by defaultCan the child override it
Environment variablesYes, through ENVYes, with a new ENV value
Default userYes, often rootYes, with USER
Entrypoint and commandYesYes, with ENTRYPOINT or CMD
Working directoryYesYes, with WORKDIR
ONBUILD triggersExecuted in the child buildNo, only avoided by changing the base
LabelsYesYes, by redefining the key
Configuration inherited from a base image

Common families of base images

Base images fall into a few recognizable families that trade size against convenience. Full distribution images include shells, package managers and debugging tools, while minimal images strip almost everything that the application does not load at run time.

FamilyExample referenceApproximate sizeC library
Full distributionubuntu:24.04, debian:bookwormAbout 25 to 50 MBglibc
Slim distributiondebian:bookworm-slimAbout 25 to 30 MBglibc
Alpine Linuxalpine:3.20About 3 to 4 MBmusl
Distrolessgcr.io/distroless/staticAbout 1 to 20 MBglibc or none
Language runtimepython:3.12-slim, node:20About 50 to 400 MBDepends on variant
Empty imagescratch0 MBNone
Typical base image families and their compressed sizes

Sizes vary between releases and architectures, so the figures above are orders of magnitude, not guarantees. The C library matters more than the size: binaries compiled against glibc may fail or behave differently on musl, which affects DNS resolution, locale handling and some Python wheels.

A base image is a role an image plays, not a separate artifact type. Any container image becomes a base image when another Dockerfile names it in FROM, which is why the term overlaps with several neighbors in the Containers topic.

TermWhat it describesRelation to the base image
Container imageAny packaged filesystem plus configurationA base image is a container image used as a starting point
Image layerOne filesystem change setThe base contributes the lowest layers
Distroless imageAn image without shell or package managerA popular choice of minimal base
Multi-stage buildSeveral FROM stages in one DockerfileEach stage has its own base; only the last ships
Golden imageAn organization-approved, hardened baseAn internal base image under governance
How the base image relates to neighboring terms

In a multi-stage build, the builder stage often uses a large SDK image while the final stage uses a minimal runtime base. Only the final stage’s base ends up in production, so the security review should focus on that final FROM line.

Choosing and pinning a base image

A good base image is the smallest one that still runs the application reliably and receives timely security updates. Teams usually evaluate compatibility first, then size and attack surface, then maintenance guarantees from the publisher.

SituationRecommended baseReason
Statically linked Go or Rust binaryscratch or distroless staticNo runtime libraries are required
Python service with native wheelsSlim glibc distributionAvoids musl incompatibilities
Java serviceJRE runtime imageExcludes the compiler and build tools
Debugging-heavy internal toolFull distributionShell and utilities aid diagnosis
Regulated workloadHardened golden imageMeets internal benchmarks and audits
Decision guide for selecting a base image

Tags such as latest or even 3.12 are mutable pointers that move when the publisher pushes an update. For reproducible builds, teams pin the base by digest, for example python:3.12-slim@sha256:..., and let an automated dependency tool propose digest updates through reviewed pull requests. This keeps builds deterministic while still delivering patches.

Security and maintenance risks of base images

Most vulnerabilities reported by container image scanning originate in the base image rather than in application code. Every package in the base expands the attack surface, and every unpatched library is inherited silently by all child images.

  • Stale bases: an image built months ago keeps old packages even if the upstream tag was patched; only a rebuild picks up fixes.
  • Untrusted publishers: images from unknown registry accounts may contain malware; prefer official or verified images and check signatures where available.
  • Running as root: many bases default to the root user, so the child image should set a non-root USER.
  • End-of-life distributions: a base whose release no longer receives updates leaves every child permanently unpatched.
  • Hidden ONBUILD steps: triggers in a parent can run unexpected commands during the child build.

Mature platform teams maintain a small catalog of approved base images, rebuild them on a fixed schedule such as weekly, sign them, and block deployments that reference unapproved bases through admission policies in the orchestration layer.

Understanding it simply

Think of a base image as the foundation of a prefabricated house. Before anyone adds walls, furniture or paint, the foundation already exists and decides how stable the whole building is. Every container starts from such a foundation, which already contains the basic tools a program needs.

If the foundation is small and well maintained, the house is lighter and safer. If it is old or cracked, every house built on it inherits the same problem. That is why engineers choose base images carefully and refresh them regularly.

Applied in practice

A platform team at a mid-sized online retailer runs about 120 microservices, most written in Python and Go. A scan shows that the services use eleven different base images, several built from a Debian release close to end of life, with more than 300 known vulnerabilities across the fleet.

The team defines two approved bases: a slim glibc Python image for Python services and a distroless static image for Go binaries. Both are pinned by digest, rebuilt every week in the continuous integration pipeline and signed before they are pushed to the internal container registry. An admission policy rejects any deployment that references another base.

After three months, the average image size falls from about 600 MB to 150 MB, cold node pulls become noticeably faster, and the open vulnerability count drops to a few dozen low-severity findings. The outcome is a smaller, more consistent and easier-to-patch fleet built on a single governed foundation.