Docker

GitLab Runner:即使設置了 DOCKER_AUTH_CONFIG,也沒有基本的身份驗證憑據

  • September 16, 2019

我正在嘗試使用私有 Docker 系統資料庫設置 gitlab 執行器服務。根據文件,設置 DOCKER_AUTH_CONFIG 環境變數並使用 docker auth 憑據填充它就足夠了:

並發 = 2 check_interval = 0

[session_server]
 session_timeout = 1800

[[runners]]
 name = "docker-shared-2"
 url = "https://gitlab.easybell.de/"
 token = "SDRWmUtpfVNb4c4xMicf"
 executor = "docker"
 environment = ["DOCKER_AUTH_CONFIG={ \"auths\": { \"xxxx\": { \"auth\": \"xxxx=\" } } }"]
 [runners.docker]
   tls_verify = false
   privileged = true
   disable_entrypoint_overwrite = false
   oom_kill_disable = false
   disable_cache = false
   volumes = ["/cache"]
   shm_size = 0
 [runners.cache]
   [runners.cache.s3]
   [runners.cache.gcs]

使用此配置,gitlab ci 作業仍然失敗,並出現以下錯誤:

ERROR: Preparation failed: Error response from daemon: Get https://xxx: no basic auth credentials (executor_docker.go:168:0s)

除了使此設置正常工作之外,我還缺少什麼或需要做什麼?

與其DOCKER_AUTH_CONFIG在 gitlab 執行器配置中設置變數,不如為 docker 守護程序設置它:

/etc/docker/config.json

{
 "auths": {
     "my.private.registry": {
       "auth": "xx=="
     }
 }
}  

引用自:https://unix.stackexchange.com/questions/501416