Base Images and Parent Layers
What you'll learn: How base images serve as the starting foundation for building container images.
What is a Base Image?
A base image is the first layer—the foundation—of a container image. It's the starting point from which all other layers are built. Think of it like the foundation of a house: everything else gets stacked on top of it.
When you create a container image, you almost always start with a base image rather than building from scratch. This base image typically contains an operating system (like Ubuntu, Alpine Linux, or Debian) and minimal utilities needed to run applications.
Parent Layers Explained
Any layer your image builds upon is called a parent layer. The base image itself is the first parent layer. When you add your application code, install dependencies, or copy configuration files, you're creating new layers on top of that parent.
Here's the hierarchy:
- Base image → The foundational OS layer (e.g.,
ubuntu:22.04) - Parent layers → Any layers between the base and your current layer
- Your layers → Custom modifications you add on top
Why Base Images Matter
Base images leverage the layer caching and reuse concept you learned earlier. If multiple container images share the same base image (say, alpine:3.18), that base layer is stored only once on disk. Every image building from that base references the same underlying layer, saving massive amounts of storage and download time.
This is why choosing the right base image matters—it affects size, security, and how much you share with other containers.
Key Takeaway: Base images are the foundational layers that provide the operating system and core utilities; all other layers stack on top, creating parent-child relationships that maximize reuse through the union filesystem.