We are using Docker containers for dev (dev container) & pipeline (gitlab CI).
Both cases use a base image of python:3.12-slim
. The dev container is defined as:
FROM python:3.12-slim
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
RUN apt-get update && \
apt-get upgrade -y && \
...
WORKDIR /app
# not recommended in docs to install poetry globally but as this is a VM this is fine
RUN pip install poetry && \
# no need for venv in dev container
poetry config virtualenvs.create false && \
poetry install
COPY . /app
Running python --version
from inside the dev container returns Python 3.12.3
.
The pipeline setup is set up as:
lint:
image: python:3.12-slim
stage: test
tags:
- docker
before_script:
- apt-get update
- apt-get upgrade -y
- pip3 install poetry
- poetry config virtualenvs.create false
- poetry install --without dev
script:
- pylint --version
- pylint app --verbose
- pylint tests --verbose
- black --version
- black . --check --verbose
- isort --version
- isort . --check --verbose
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "web"
The pipeline however will fail on poetry install
due to:
The currently activated Python version 3.12.0 is not supported by the project (3.12.3).
Looking into the Dockerfile for this image it appears 3.12.3 is correct. How could it be that the pipeline is grabbing an older Python version?
What minor version does docker image python:3.12-slim use?
Any 3.12.X. The image tag is updated with each minor release.
How could it be that the pipeline is grabbing an older python version?
An old version of the image tag is cached on the machine. Because it exists, new version is not fetched. This is a configuration in gitlab-runner, see for example GitLab runner pulls image for every job .
If you intend to use 3.12.3, then the docker python project happens to also have :3.12.3-slim docker tag.