我正在尝试使用私有 Docker 注册表设置 gitlab 运行程序服务。根据文档,设置 DOCKER_AUTH_CONFIG 环境变量并使用 docker auth 凭据填充它就足够了:
并发 = 2 检查间隔 = 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)
除了使此设置正常工作之外,我还缺少或需要什么?
答案1
不需要DOCKER_AUTH_CONFIG
在 gitlab 运行程序配置中设置变量,而是需要为 docker 守护进程设置变量:
/etc/docker/config.json
{
"auths": {
"my.private.registry": {
"auth": "xx=="
}
}
}