3.3.1.1 Ubuntu Base Images
A focused guide to Ubuntu Base Images, connecting core concepts with practical Docker and container operations.
Ubuntu base images provide a containerized installation of the Ubuntu Linux distribution, offering broad package availability through apt and strong compatibility with software commonly developed and tested against Ubuntu, at the cost of a larger image size compared to more minimal alternatives.
Using an Ubuntu Base Image
The official Ubuntu image is available tagged by release version, allowing a build to target a specific, well-known Ubuntu release rather than an indeterminate "latest" version.
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y python3 python3-pip
COPY . /app
WORKDIR /app
CMD ["python3", "app.py"]
Why Teams Choose Ubuntu as a Base
Ubuntu's package repositories are extensive and well-maintained, and many third-party installation instructions are written and tested specifically against Ubuntu, which can reduce friction when installing less common dependencies that might require extra effort on a more minimal distribution.
apt-get install -y some-specialized-package
Software with installation instructions that assume an Ubuntu or Debian-based system tends to work with minimal adaptation on an Ubuntu base image.
Image Size Tradeoffs
Ubuntu base images are noticeably larger than minimal alternatives like Alpine, since they include a broader set of default packages and documentation; this size difference matters more in contexts where image pull time or storage footprint at scale is a significant concern.
docker images ubuntu
docker images alpine
Cleaning Up After Package Installation
Because apt-get leaves behind package lists and cache files by default, cleaning these up within the same RUN instruction that installed packages keeps the resulting layer as small as reasonably possible.
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
Why Ubuntu Base Images Remain a Common Choice
Despite their larger size relative to minimal alternatives, Ubuntu base images remain a popular default specifically because of their broad compatibility and familiarity, making them a pragmatic choice when development speed and dependency compatibility matter more than achieving the smallest possible image.