Skip to content

Python#

The Lagoon python Docker image. Based on the official Python Alpine images.

Supported Versions#

  • 2.7 (available for compatibility only, no longer officially supported) - uselagoon/python-2.7
  • 3.7 (available for compatibility only, no longer officially supported) - uselagoon/python-3.7
  • 3.8 Dockerfile (Security Support until October 2024) - uselagoon/python-3.8
  • 3.9 Dockerfile (Security Support until October 2025) - uselagoon/python-3.9
  • 3.10 Dockerfile (Security Support until October 2026) - uselagoon/python-3.10
  • 3.11 Dockerfile (Security Support until October 2027) - uselagoon/python-3.11
  • 3.12 Dockerfile (Security Support until October 2028) - uselagoon/python-3.12

Tip

We stop updating and publishing EOL Python images usually with the Lagoon release that comes after the officially communicated EOL date: https://devguide.python.org/versions/#versions. Previous published versions will remain available.

Lagoon adaptions#

The default exposed port of Python containers is port 8800.

Persistent storage is configurable in Lagoon, using the lagoon.type: python-persistent. See the docs for more info

Use the following labels in your docker-compose.yml file to configure it: lagoon.persistent = use this to define the path in the container to use as persistent storage - e.g. /app/files lagoon.persistent.size = this to tell Lagoon how much storage to assign this path

If you have multiple services that share the same storage, use this lagoon.persistent.name = (optional) use this to tell Lagoon to use the storage defined in another named service

docker-compose.yml snippet#

docker-compose.yml
python:
    build:
    # this configures a build from a Dockerfile in the root folder
        context: .
        dockerfile: Dockerfile
    labels:
    # tells Lagoon this is a python service, configured with 500MB of persistent storage at /app/files
        lagoon.type: python-persistent
        lagoon.persistent: /app/files
        lagoon.persistent.size: 500Mi
    ports:
    # local development only
          # this exposes the port 8800 with a random local port
          # find it with `docker compose port python 8800`
        - "8800"
    volumes:
    # local development only
        # mounts a named volume (files) at the defined path for this service to replicate production
        - files:/app/files