Improved base container images for Python.
  • Dockerfile 100%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-03 22:13:36 +02:00
.forgejo/workflows Add a shared mobile home to the last promotion job too 2026-09-03 22:13:36 +02:00
alpine Add support for PATH overrides in ~/.bin 2026-09-03 22:12:54 +02:00
debian Add support for PATH overrides in ~/.bin 2026-09-03 22:12:54 +02:00
LICENSE Replace docker with podman, refactor everything 2025-01-19 00:45:53 +01:00
README.md Improve README.md 2026-09-01 22:07:53 +02:00

Pythonium - improved base container images for Python

Using the image

This image is a basic wrapper layer on top of the standard official Python image.

It adds:

  • a pre-made unprivileged user app for the deployed application to use
  • a pre-made virtual environment, which is always active in the container and belongs to the unprivileged user

The repo exposes two editions of each tag based on the official Python images on Docker Hub:

  • :<PYTHON-VERSION>-alpine<ALPINE-VERSION> (Alpine Linux, e.g. :3.14-alpine3.24)
  • :<PYTHON-VERSION>-debian-<DEBIAN-VERSION> (Debian, e.g. :3.14-debian-trixie)

Each image is also published under an immutable tag: :<PYTHON-VERSION>-<FLAVOR-AND-VERSION>-<CREATED-AT>, e.g. :3.14-alpine3.24-2026-08-28t23-28-21-0000.

Building the images

Building the image

buildah build \
  --build-arg PYTHON_VERSION=3.14 \
  --build-arg ALPINE_VERSION=3.24 \
  --tag forge.bolzga.net/solid-containers/pythonium:3.14-alpine3.24 \
  alpine/

buildah build \
  --build-arg PYTHON_VERSION=3.14 \
  --build-arg DEBIAN_VERSION=trixie \
  --tag forge.bolzga.net/solid-containers/pythonium:3.14-debian-trixie \
  debian/

Available build args

  • PYTHON_VERSION: Python version for the base image: (default: 3.14)
    • one of: 3.10, 3.11, 3.12, 3.13, 3.14
  • ALPINE_VERSION: Alpine Linux version for the base image (for Alpine Linux—based edition only) (default: 3.24)
  • DEBIAN_VERSION: Debian version for the base image (for Debian—based edition only) (default: trixie)
  • USER_NAME: name of the unprivileged user to create (default: app)
  • USER_GROUP: primary group name for the unprivileged user to create (default: app)
  • USER_HOME: path to the home of the unprivileged user (default: /home/${USER_NAME})
  • USER_SHELL: shell to assign as default for the unprivileged user (default: /sbin/nologin)
  • USER_UID: UID of the unprivileged user (default: 2000)
  • USER_GID: GID of the unprivileged user's primary group (default: 2000)
  • VIRTUAL_ENV: path to the globally-available virtual environment (default: ${USER_HOME}/.venv)

Example Containerfile for a Flask app using Pythonium

Don't use this in real code, this is a simple Containerfile for illustrative purposes only!

FROM forge.bolzga.net/solid-containers/pythonium:3.14-alpine3.24

RUN --mount=type=bind,target=/requirements.txt,source=requirements.txt \
    --mount=type=cache,target=~/.cache/pip,sharing=locked \
  pip install -r /requirements.txt

ENV FLASK_APP="package.app"
EXPOSE 8000

ENTRYPOINT [ "python" ]
CMD [ "-m", "flask", "run" ]

For more detailed examples for each edition (e.g. installation of system-wide packages) check out docs for the Alpine Linux—based edition and for the Debian—based edition.