DirectorySecurity AdvisoriesPricing
Sign in
Directory
python-fips logoFIPS

python-fips

packaged by Chainguard

Last changed
Request a free trial

Contact our team to test out this image for free. Please also indicate any other images you would like to evaluate.

Tags
Overview
Comparison
Provenance
Specifications
SBOM
Vulnerabilities
Advisories

Chainguard Container for python-fips

Chainguard Containers are regularly-updated, secure-by-default container images.

Download this Container Image

For those with access, this container image is available on cgr.dev:

docker pull cgr.dev/ORGANIZATION/python-fips:latest

Be sure to replace the ORGANIZATION placeholder with the name used for your organization's private repository within the Chainguard Registry.

Description

The python-fips Chainguard Image provides a FIPS-enabled Python runtime suitable for workloads such as web applications, CLI utilities, interfacing with APIs, or other tasks.

Compatibility Notes

Where possible, the python-fips Chainguard Image is built for compatibility with the Docker official image for Python.

The python-fips Chainguard Image ships with a validated redistribution of the OpenSSL's FIPS provider module. For more on FIPS support in Chainguard Images, consult the guide on FIPS-enabled Chainguard Images on Chainguard Academy

By default, the python-fips Chainguard Image runs as a non-root user. You may need to use USER root to perform tasks requiring elevated privileges.

The entrypoint for the python Chainguard Image is /usr/bin/python. Commands run as part of docker run or a CMD statement in a Dockerfile will be passed as arguments to python.

Variants

We have two image variants available:

  • A python-fips:latest-dev variant that contains the pip and apk package managers and the bash, ash, and sh shells.
  • A minimal runtime variant that does not contain shells and package managers for additional security.

To pull the minimal runtime variant from cgr.dev:

docker pull cgr.dev/ORGANIZATION/python-fips:latest

To pull the dev variant:

docker pull cgr.dev/ORGANIZATION/python-fips:latest-dev

Getting Started

Example: Test for Unapproved FIPS Algorithm

The MD5 algorithm is commonly used to verify data integrity. According to the FIPS framework, MD5 is not suitable for applications like SSL certificates or digital signatures that rely on collision resistance for digital security. Since MD5 is not approved under the FIPS framework, we can test for FIPS compliance by attempting to use this algorithm. This should result in an error.

First, create a project folder for our test:

mkdir -p ~/fips-test && cd $_

Next, create a Python script that attempts to use the MD5 algorithm:

cat << 'EOF' > fips-test.py
import hashlib
import hmac

print("SHA256 HMAC " + hmac.HMAC(b"myverylongkey", b"somedata", digestmod=hashlib.sha256).hexdigest())

try:
    print("MD5 HMAC " + hmac.HMAC(b"myverylongkey", b"somedata", digestmod=hashlib.md5).hexdigest())
except:
    print("MD5 HMAC blocked")

try:
    print("MD5 Digest usedforsecurity=False " + hashlib.md5(b"test_str", usedforsecurity=False).hexdigest())
except:
    print("MD5 Digest non-security blocked")

try:
    print("MD5 Digest default " + hashlib.md5(b"test_str").hexdigest())
except:
    print("MD5 Digest default blocked")
    hashlib.md5(b"test_str").hexdigest()
EOF

Create a Dockerfile for our image build:

cat << EOF > Dockerfile
FROM cgr.dev/ORGANIZATION/python-fips:3.14

WORKDIR /app

ENV CHAINGUARD_LEGACY_ALLOWED=0

COPY fips-test.py .

USER root

CMD ["fips-test.py"]
EOF

Build the image:

docker build --no-cache . -t fips-test

Finally, run the test:

docker run --rm --env CHAINGUARD_LEGACY_ALLOWED=0 fips-test

This should produce output similar to the following:

$ docker run --env CHAINGUARD_LEGACY_ALLOWED=0 fips-test
SHA256 HMAC cc27e1336ba76d78daf3e726cf7accef2c6ecbbe40c8832433f721a55deb425f
MD5 HMAC blocked
MD5 Digest usedforsecurity=False 74e710825309d622d0b920390ef03edf
MD5 Digest default blocked
Traceback (most recent call last):
  File "/app/fips-test.py", line 17, in <module>
    print("MD5 Digest default " + hashlib.md5(b"test_str").hexdigest())
                                  ~~~~~~~~~~~^^^^^^^^^^^^^
_hashlib.UnsupportedDigestmodError: [digital envelope routines] unsupported

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/fips-test.py", line 20, in <module>
    hashlib.md5(b"test_str").hexdigest()
    ~~~~~~~~~~~^^^^^^^^^^^^^
_hashlib.UnsupportedDigestmodError: [digital envelope routines] unsupported

MD5 digest is allowed for non-security purposes, such as fingerprinting files - as commonly used in Cloud bucket storage. It is not allowed to be used for security purposes such as HMAC and digital signatures. This is as per FIPS 140-3 I.G.2.4.A implementation guidance.

In Chainguard containers, the default value for the environment variable CHAINGUARD_LEGACY_ALLOWED is 1 - permitting MD5 digest calculation. You can change this value to zero as demonstrated above to block MD5 digest calculation by default and then you can use the upstream usedforsecurity=False optional argument to selectively allow MD5 calculation on per-call basis.

Irrespective of the CHAINGUARD_LEGACY_ALLOWED setting, HMAC-MD5 calculation with non-approved digests is blocked:

$ docker run --env CHAINGUARD_LEGACY_ALLOWED=1 fips-test
SHA256 HMAC cc27e1336ba76d78daf3e726cf7accef2c6ecbbe40c8832433f721a55deb425f
MD5 HMAC blocked
MD5 Digest usedforsecurity=False 74e710825309d622d0b920390ef03edf
MD5 Digest default 74e710825309d622d0b920390ef03edf

Example: Minimal CLI Application

The following provides an example of a CLI application that does not require additional Python dependencies.

First, create a project folder for the example and change the working directory to that folder:

mkdir -p ~/python-cli && cd $_

Next, create the Python script:

cat << 'EOF' > app.py
from sys import argv

if len(argv) < 2:
    print("Hello, Linky! 🐙")
else:
    print(f"Hello, {argv[1]}!")
EOF

Create a Dockerfile for our image build:

cat << EOF > Dockerfile
FROM cgr.dev/ORGANIZATION/python-fips:latest

WORKDIR /cli-app

COPY app.py .

ENTRYPOINT [ "python", "app.py"]
EOF

Make sure to replace the value of the ORGANIZATION placeholder with the name of your organization.

Build the image:

docker build . -t python-cli

Run the container with the following:

docker run python-cli

You should see the following output:

Hello, Linky! 🐙

You can also run the CLI application with an argument:

docker run python-cli "FIPS-Compliant Chainguard User"

Example: Web Application with Multi-Stage Build

If you require additional packages that can be installed with the pip package manager, we recommend using a multistage build. This process involves installing packages in a virtual environment using the latest-dev variant, then copying this environment over to the minimal runtime image. The following example uses a multi-stage build to install packages necessary to run a Flask web application.

First, create a project folder for the example:

mkdir -p ~/python-web-app && cd $_

Next, create the script for our Flask web application:

cat << 'EOF' > app.py
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    """Example index page."""
    octopuses = '🐙' * 10
    return f'<h1>Linky Is Best</h1><p>{octopuses}</p>'


if __name__ == "__main__":
    app.run(debug=True)
EOF

Next, create a requirements.txt file listing dependencies:

cat << 'EOF' > requirements.txt
Flask
gunicorn
EOF

Finally, let's create a Dockerfile for our image build:

cat << EOF > Dockerfile
FROM cgr.dev/ORGANIZATION/python-fips:latest-dev AS dev

WORKDIR /flask-app

RUN python -m venv venv
ENV PATH="/flask-app/venv/bin":$PATH
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt

FROM cgr.dev/ORGANIZATION/python-fips:latest

WORKDIR /flask-app

COPY app.py app.py
COPY --from=dev /flask-app/venv /flask-app/venv
ENV PATH="/flask-app/venv/bin:$PATH"

EXPOSE 8000

ENTRYPOINT ["python", "-m", "gunicorn", "-b", "0.0.0.0:8000", "app:app"]
EOF

Again, make sure to replace the value of the ORGANIZATION placeholder variable with the name of your organization.

Build the image:

docker build . -t python-web-app

Run a container to serve the web application:

docker run -p 8000:8000 python-web-app

The application should now be accessible at http://localhost:8000/.

Documentation and Resources

What are Chainguard Containers?

Chainguard's free tier of Starter container images are built with Wolfi, our minimal Linux undistro.

All other Chainguard Containers are built with Chainguard OS, Chainguard's minimal Linux operating system designed to produce container images that meet the requirements of a more secure software supply chain.

The main features of Chainguard Containers include:

For cases where you need container images with shells and package managers to build or debug, most Chainguard Containers come paired with a development, or -dev, variant.

In all other cases, including Chainguard Containers tagged as :latest or with a specific version number, the container images include only an open-source application and its runtime dependencies. These minimal container images typically do not contain a shell or package manager.

Although the -dev container image variants have similar security features as their more minimal versions, they include additional software that is typically not necessary in production environments. We recommend using multi-stage builds to copy artifacts from the -dev variant into a more minimal production image.

Need additional packages?

To improve security, Chainguard Containers include only essential dependencies. Need more packages? Chainguard customers can use Custom Assembly to add packages, either through the Console, chainctl, or API.

To use Custom Assembly in the Chainguard Console: navigate to the image you'd like to customize in your Organization's list of images, and click on the Customize image button at the top of the page.

Learn More

Refer to our Chainguard Containers documentation on Chainguard Academy. Chainguard also offers VMs and Librariescontact us for access.

Trademarks

This software listing is packaged by Chainguard. The trademarks set forth in this offering are owned by their respective companies, and use of them does not imply any affiliation, sponsorship, or endorsement by such companies.

Licenses

Chainguard's container images contain software packages that are direct or transitive dependencies. The following licenses were found in the "latest" tag of this image:

  • Apache-2.0

  • BSD-1-Clause

  • BSD-2-Clause

  • BSD-3-Clause

  • BSD-4-Clause-UC

  • CC-PDDC

  • GCC-exception-3.1

For a complete list of licenses, please refer to this Image's SBOM.

Software license agreement

Compliance

Chainguard Containers are SLSA Level 3 compliant with detailed metadata and documentation about how it was built. We generate build provenance and a Software Bill of Materials (SBOM) for each release, with complete visibility into the software supply chain.

SLSA compliance at Chainguard

This image helps reduce time and effort in establishing PCI DSS 4.0 compliance with low-to-no CVEs.

PCI DSS at Chainguard

This is a FIPS validated image for FedRAMP compliance.

This image is STIG hardened and scanned against the DISA General Purpose Operating System SRG with reports available.

Learn more about STIGsGet started with STIGs

Image contains multiple maintained release tracks and is eligible for end of life support.


Related images
python logo

python


Category
Featured
FIPS
STIG

The trusted source for open source

Talk to an expert
PrivacyTerms

Product

Chainguard ContainersChainguard LibrariesChainguard VMsChainguard OS PackagesChainguard ActionsChainguard Agent SkillsIntegrationsPricing
© 2026 Chainguard, Inc. All Rights Reserved.
Chainguard® and the Chainguard logo are registered trademarks of Chainguard, Inc. in the United States and/or other countries.
The other respective trademarks mentioned on this page are owned by the respective companies and use of them does not imply any affiliation or endorsement.