docker image python:3.12-slim 使用哪个小版本?

问题描述 投票:0回答:1

我们使用 docker 容器进行开发(开发容器)和管道(gitlab CI)。

两种情况都使用

python:3.12-slim
的基础图像。开发容器定义为:

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

从开发容器内部运行

python --version
将返回
Python 3.12.3

管道设置设置为:

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"

但是,管道将在

poetry install
上失败,原因是:

The currently activated Python version 3.12.0 is not supported by the project (3.12.3).

查看此图像的 Dockerfile 看来 3.12.3 是正确的。管道怎么会抓取较旧的 python 版本?

谢谢

python docker gitlab gitlab-ci-runner vscode-devcontainer
1个回答
0
投票

docker image python:3.12-slim 使用哪个小版本?

任何 3.12.X。图像标签随每个次要版本更新。

管道怎么可能获取较旧的 python 版本?

旧版本的图像标签缓存在计算机上。因为它存在,所以不会获取新版本。这是 gitlab-runner 中的配置,请参阅示例 GitLab runner 为每个作业拉取镜像 .

如果您打算使用 3.12.3,那么上游项目恰好支持 3.12.3-slim。

© www.soinside.com 2019 - 2024. All rights reserved.