rhel10/python-312-minimal

Python 3.12 Minimal

Red Hat
Updated
Overview

Features

Release categoryGenerally Available
Privilege modeUnprivileged

Download this image

This will require authentication. View other options.

Description

Because the minimal and full images work similarly, we document here only the differences and limitations of the minimal container image. For the documentation of common features see the full container image docs.

Description

The full container image is a universal base image to build your containerized applications on top of. However, its universal nature means that the resulting containers it produces consume a lot of disk space. This is caused mainly by the fact that the image contains npm, compilers, header files and some other packages one might need to install and deploy their applications.

Because size does matter for us and our customers, we have prepared this minimal container image with very limited subset of installed packages. There are no compilers, no header files, no npm etc and the yum package manager is replaced with a minimalistic reimplementation called microdnf, making the resulting container images much smaller. This creates some limitations but we provide ways to workaround them.

Limitations

  1. There is only a very limited subset of packages installed. They are choosen carefully to satisfy most of the Python apps but your app might have some special needs.
  2. There is no npm and nodejs.
  3. There are no compilers and header files. Installation from Python wheels should still work but compilation from a source code is not supported out of the box.

In the next chapter, we provide three possible workarounds for the mentioned limitations of the minimal container image.

Possible solutions for the limitations

Use the full container image

It's easy at that. If you don't want to write your own Dockerfile and disk space is not a problem, use the full universal container image and you should be fine.

Build your own container image on top of the minimal container image

Let's say that your application depends on uwsgi. uwsgi cannot be installed from Python wheel and has to be compiled from source which requires some additional packages to be installed - namely gcc for the compilation itself and python3.12-devel containing Python header files.

To solve that problem, you can use all the pieces provided by the minimal container image and just add one more step to install the missing dependencies:

FROM python-312-minimal

# Add application sources to a directory that the assemble script expects them
# and set permissions so that the container runs without root access
USER 0
ADD app-src /tmp/src
RUN /usr/bin/fix-permissions /tmp/src

# Install packages necessary for compiling uwsgi from source
RUN microdnf install -y gcc python3.12-devel
USER 1001

# Install the dependencies
RUN /usr/libexec/s2i/assemble

# Set the default command for the resulting image
CMD /usr/libexec/s2i/run

If you do it this way, your problem with the missing packages is solved. But there is also one disadvantage: the resulting runtime image contains unnecessary compiler and Python header files. How to solve this? Uninstalling them at the end of the Dockerfile is not really a solution but we have one. Keep reading.

Build on full image, run on minimal image

Did you know that you can copy files from one image to another one during a build? That's the feature we are gonna use now. We use the full container image with all compilers and other usefull packages installed to build our app and its dependencies and we then move the result including the whole virtual environemnt to the minimal container image.

This app needs mod_wsgi and to install (compile it from source) it, we'll need: httpd-devel for header files, gcc and redhat-rpm-config as a compiler and configuratuion and finally python3.12-devel containing Python header files. There is no need to install those packages manually because the full container image already contains them. However, the application needs httpd as a runtime dependency so we need to install it to the minimal container image as well.

# Part 1 - build

FROM python-312 as builder

# Add application sources to a directory that the assemble script expects them
# and set permissions so that the container runs without root access
USER 0
ADD app-src /tmp/src
RUN /usr/bin/fix-permissions /tmp/src
USER 1001

# Install the application's dependencies from PyPI
RUN /usr/libexec/s2i/assemble

# Part 2 - deploy

FROM python-312-minimal

# Copy app sources together with the whole virtual environment from the builder image
COPY --from=builder $APP_ROOT $APP_ROOT

# Install httpd package - runtime dependency of our application
USER 0
RUN microdnf install -y httpd
USER 1001

# Set the default command for the resulting image
CMD /usr/libexec/s2i/run

This way, the resulting container image does contain only necessary dependencies and it's much lighter.

Products using this container

Type

Builder image

Stream

Single-stream

Size

57.2 MB

(162.6 MB uncompressed)

Digest

Category

Programming Languages & Runtimes
SecuritySpecifications

Image specifications

The following information was extracted from the dockerfile and other sources.

Canonical image IDPython 3.12 Minimal
SummaryMinimal platform for building and running Python 3.12 applications
DescriptionPython 3.12 available as container is a base platform for building and running various Python 3.12 applications and frameworks. Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python's elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
ProviderRed Hat
MaintainerSoftwareCollections.org <sclorg@redhat.com>
Repository nameubi10/python-312-minimal
Image version10.1
Architectureamd64
Usages2i build https://github.com/sclorg/s2i-python-container.git --context-dir=3.12-minimal/test/setup-test-app/ ubi10/python-312-minimal python-sample-app
Exposed ports8080:http
Working directory/opt/app-root/src
PackagesContainerfileGet this image
Terms & conditionsBefore downloading or using this Container, you must agree to the Red Hat subscription agreement located at redhat.com/licenses. If you do not agree with these terms, do not download or use the Container. If you have an existing Red Hat Enterprise Agreement (or other negotiated agreement with Red Hat) with terms that govern subscription services associated with Containers, then your existing agreement will control.

Registry tokens

Use a registry service account token to authenticate your container client. This allows you to pull images without using your personal Red Hat credentials, which is recommended for CI/CD pipelines and automated deployments.

Using Podman login


Image identifiers

Red Hat login

Use the following instructions to get images from a Red Hat container registry using your Red Hat login.

Using Podman login


Image identifiers


Unauthenticated

Use the following instructions to get images from a Red Hat container registry without providing authentication.

Update to new container registryTo support our existing users and users to come, we will be transitioning our product portfolio and customers to a new container registry. The new registry uses standard OAuth mechanisms to provide customers with the ability to configure their systems to pull containerized content using static tokens or their Red Hat login. Customers are encouraged to begin using the new registry as their preferred authentication method.

Using podman

Use the following command(s) from a system with podman installed.


Image identifiers

Getting source containers

Source code is available for all Red Hat UBI-based images in the form of downloadable containers. Here are a few things you should know about Red Hat source containers.

  • Although they are packaged as containers, source containers cannot be run. So instead of using podman pull to get them to your system, use the skopeo command.
  • Source containers are named based on the binary containers they represent. So, for example, to get the source container for a particular standard RHEL UBI 8 container (registry.access.redhat.com/ubi8/ubi8.1-397) you simply append -source to get the source code container for that image (registry.access.redhat.com/ubi8/ubi8.1-397-source).
  • Once a source container is copied to a local directory, you can use a combination of tar,gzip, and rpm commands to work with that content.

Step one

Use skopeo to copy the source image to a local directory

Step two

Inspect the image

Step three

Untar the contents

Step four

Begin examining and using the content.

Red Hat logoLinkedInYouTubeFacebookTwitter

Platforms

Products & services

Try, buy, sell

Help

About Red Hat Ecosystem Catalog

The Red Hat Ecosystem Catalog is the official source for discovering and learning more about the Red Hat Ecosystem of both Red Hat and certified third-party products and services.

We’re the world’s leading provider of enterprise open source solutions—including Linux, cloud, container, and Kubernetes. We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2025 Red Hat, LLC
Feedback