docker Gitlab CI/CD错误无法使用指定的策略提取映像“python 3.9”[如果不存在]

42fyovps  于 2023-02-15  发布在  Docker
关注(0)|答案(2)|浏览(218)

我是devops新手,尝试使用Gitlab CI/CD和本地docker runner进行pytest。我的工作失败了,错误如下:

WARNING: Failed to pull image with policy "if-not-present": invalid reference format (manager.go:237:0s)
ERROR: Job failed: failed to pull image "python 3.9" with specified policies [if-not-present]: invalid reference format (manager.go:237:0s)

我该怎么修呢?
我的. gitlab-ci. yml

stages:
  - test

image: python 3.9

run_tests:
  stage: test
  before_script:
    - pip install -r requirements.txt
  script:
    - pytest -v -s
  tags:
    - docker-local

我的本地跑步者. yml

services:
  runner:
    container_name: gitlab-runner
    image: gitlab/gitlab-runner:latest
    volumes:
      - ./runner/:/etc/gitlab-runner
      - /var/run/docker.sock:/var/run/docker.sock
    restart: always

config.toml

concurrent = 1
check_interval = 0
shutdown_timeout = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "test_runner_local"
  url = "https://my_url"
  id = 8
  token = "TOKEN"
  token_obtained_at = data
  token_expires_at = data
  executor = "docker"
  [runners.custom_build_dir]
  [runners.cache]
    MaxUploadedArchiveSize = 0
    [runners.cache.s3]
    [runners.cache.gcs]
    [runners.cache.azure]
  [runners.docker]
    pull_policy = ["if-not-present"]
    tls_verify = false
    image = "python:3.9"
    privileged = false
    disable_entrypoint_overwrite = false
    oom_kill_disable = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0

如果我删除config.toml中的pull_policy字段或将其值替换为'always'-错误不会消失。

jk9hmnmh

jk9hmnmh1#

你没看到冒号,试试这个:

stages:
  - test

image: python:3.9  # you miss ":" 

run_tests:
  stage: test
  before_script:
    - pip install -r requirements.txt
  script:
    - pytest -v -s
  tags:
    - docker-local

此外,在www.example.com上有免费的CI/CD配额gitlab.com,您可以在线测试您的工作是否正常,然后在本地测试,可以保存一点调试时间。

xienkqul

xienkqul2#

尝试

pull_policy = "if-not-present"

例如这里的例子https://docs.gitlab.com/runner/executors/docker.html#configure-how-runners-pull-images

相关问题