3.3.2 Runtime Base Images
A focused guide to Runtime Base Images, connecting core concepts with practical Docker and container operations.
Runtime base images provide a particular language's interpreter or virtual machine pre-installed on top of an operating system base, serving as the foundation for applications written in that language without requiring the runtime to be installed separately in every build.
What a Runtime Base Image Adds
Beyond a plain operating system base, a runtime base image includes the specific language environment an application needs to execute — an interpreter for dynamic languages, or a virtual machine for languages that compile to an intermediate bytecode.
FROM python:3.12-slim
FROM node:20-alpine
FROM eclipse-temurin:21-jre
Each of these provides a ready-to-use runtime for its respective language, eliminating the need to manually install and configure that runtime from a plain operating system base image.
Matching Runtime Versions Precisely
Because application behavior can depend on the exact runtime version, pinning a specific version of a runtime base image, rather than relying on a loosely specified major version, helps ensure consistent behavior across builds.
FROM python:3.12.3-slim
Runtime-Only vs. Full Development Images
Many runtime base images come in multiple variants: a fuller image including build tools and a compiler suitable for development, and a slimmer runtime-only image intended for the final production build, often used together in a multi-stage build.
FROM python:3.12 AS build
RUN pip install --target=/deps -r requirements.txt
FROM python:3.12-slim
COPY --from=build /deps /deps
COPY . /app
Choosing a Runtime Base Image Variant
The choice between a full, slim, or Alpine-based variant of a given runtime image generally follows the same tradeoffs as choosing between operating system bases more broadly: size and security surface versus compatibility and convenience.
docker images python
Why Runtime Base Images Matter
Runtime base images remove a substantial amount of repetitive setup work from every application written in a given language, letting a Dockerfile focus on application-specific concerns rather than re-installing and configuring a language runtime from scratch in every project.