Gitlab Runner 无法使用 Nexus 注册表中的 docker 镜像

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

所以我有一个 Gitlab instanz、一个 Gitlab 运行器和一个 Nexus 服务器。
因为我们目前使用的是 Github 项目中的独立注册表,所以我们也希望将 docker 注册表切换到 Nexus。除了运行程序本身正在使用的 docker 映像之外,一切正常。
以下是获取 Gitlab 运行程序的 docker 镜像的两种不同方法:

image: jenkins.intern.de/pipeline-env:latest
# image: nexus.intern.de/docker-group/test/pipeline-env:latest

第一个工作正常,但第二个不断失败,并出现以下错误:

Running with gitlab-runner 16.3.0 (8ec04662)
  on debian U7maLHgP, system ID: s_bb2cc94b24c5
Preparing the "docker" executor
00:01
Using Docker executor with image nexus.intern.de/docker-group/test/pipeline-env:latest ...
Pulling docker image nexus.intern.de/v2/docker-group/test/pipeline-env:latest ...
WARNING: Failed to pull image with policy "always": Error response from daemon: Head "https://nexus.intern.de/v2/docker-group/test/pipeline-env/manifests/latest": no basic auth credentials (manager.go:237:0s)
ERROR: Job failed: failed to pull image "nexus.intern.de/docker-group/test/pipeline-env:latest" with specified policies [always]: Error response from daemon: Head "https://nexus.intern.de/v2/docker-group/test/pipeline-env/manifests/latest": no basic auth credentials (manager.go:237:0s)

我在我的工作站本地运行的 gitlab 运行程序。当我在我的工作站上本地使用 docker 命令时,一切都很好,我可以毫无问题地进行 docker 登录、docker 拉取、docker 推送。

Nexus 服务器为我提供了以下 URL,用于将图像拉取和推送到注册表:

https://nexus.intern.de/repository/docker-group/
,我还尝试将名称 repository 放入 url 中,但失败并出现相同的错误。所以我有点不知该去哪里解决这个问题。

有什么方法可以查看问题是否出在 gitlab 或 nexus 配置上。我可能错过了一些东西。任何想法都将受到高度赞赏!

docker gitlab gitlab-ci nexus gitlab-ci-runner
1个回答
0
投票

这可以通过 Gitlab 实例提供 DOCKER_AUTH_CONFIG 变量来解决。

感谢@KamilCuk 指出正确的文档:https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#use-statically-defined-credentials

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