如何在Gitlab-ci中登录docker账户

Omi*_*mid 12 gitlab docker gitlab-ci

我已经订阅了docker帐户的 Pro 计划,以提高我的自托管 Gitlab CI 作业的速率限制。然后在服务器上使用以下命令成功登录:

$ sudo docker login -u user -p *******
Run Code Online (Sandbox Code Playgroud)

这是我的.gitlab-ci.yml文件:

image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine

unittest:
  stage: testing
  services:
    - mysql:latest
  script:
    - ./vendor/bin/phpunit --colors --stop-on-failure
Run Code Online (Sandbox Code Playgroud)

但是当工作开始时,我仍然收到此错误:

Running with gitlab-runner 13.6.0 (8fa89735)
  on fafa-group-runner n7oiBzAk
Preparing the "docker" executor
30:53
Using Docker executor with image edbizarro/gitlab-ci-pipeline-php:7.3-alpine ...
Starting service mysql:latest ...
Pulling docker image mysql:latest ...
ERROR: Preparation failed: Error response from daemon: toomanyrequests: You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limit (docker.go:142:4s)
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?

BMi*_*tch 7

您以 root 用户身份在主机上执行了 docker 登录。然而,图像是由 GitLab 运行程序拉取的,该运行程序将是另一个用户,可能是容器化的。

配置运行程序注册表凭据的说明有多个选项,包括DOCKER_AUTH_CONFIG在项目.gitlab-ci.yml或运行程序的config.toml. ~/.docker/config.json该变量包含其中包含注册表凭据的内容。

  • 您的意思是我应该在“设置 > CI/CD > 变量”中添加“DOCKER_AUTH_CONFIG”作为变量,其中包含“~/.docker/config.json”的内容作为值? (3认同)