Gitlab运行程序拒绝访问以推送构建的映像

时间:2018-07-13 09:24:50

标签: gitlab-ci gitlab-ci-runner

我在将使用gitlab-runner构建的映像推送到gitlab存储库时遇到问题。

我的gitlab-ci.yml:

image: docker:latest
services:
- docker:dind

stages:
- build
- release

variables:
TEST_IMAGE: registry.gitlab.com/myhost/haproxy:$CI_COMMIT_REF_NAME
RELEASE_IMAGE: registry.gitlab.com/myhost/haproxy:latest

before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN gitlab.com

build:
stage: build
script:
- docker build --pull -t $TEST_IMAGE .
- docker push $TEST_IMAGE

release:
stage: release
script:
- docker pull $TEST_IMAGE
- docker tag $TEST_IMAGE $RELEASE_IMAGE
- docker push $RELEASE_IMAGE
only:
- master

泊坞窗登录有效-我获得了“登录成功”,但在推送时却得到了:

$ docker push $TEST_IMAGE
The push refers to repository [registry.gitlab.com/myhost/haproxy]
d77ab2f42dd4: Preparing
c70258f465dd: Preparing
96b45c1aa07c: Preparing
28587e66f3e8: Preparing
21b59fc0e3a3: Preparing
9c46f426bcb7: Preparing
9c46f426bcb7: Waiting
denied: access forbidden
ERROR: Job failed: exit code 1

Runner在我自己的服务器上,我正在推送到gitlab.com

我还在本地计算机上检查了在终端命令中执行的脚本,例如脚本:登录,生成和推送以及所有工作,但是如果我在本地运行运行程序,注册并完成工作,那么我也将被禁止访问。 / p>

所以我认为问题出在跑步者上,博。 我检查了gitlab-runner版本从10.6到最新的11.0

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

因此问题出在注册表地址错误-应该是Registry.gitlab.com

它误导了我,即使没有“ registry”前缀,它也会在终端显示“已登录”,因此最好的解决方案是在gitlab-ci.yml登录期间使用内置变量:

docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY 
相关问题