我有以下gitlab ci工作:
image: docker:stable
services:
- docker:dind
stages:
- debug
Debug registry login:
stage: debug
script:
- docker login --username "$CI_REGISTRY_USER" --password "$CI_REGISTRY_PASSWORD" registry.exemple.com:port/
但是作业失败,并显示以下错误:
Error response from daemon:
Get https://registry.exemple.com:port/v2/: net/http:
request canceled while waiting for connection
(Client.Timeout exceeded while awaiting headers)
正确设置了“$ CI_REGISTRY_USER”和“$ CI_REGISTRY_PASSWORD”,我试图回显它们,并显示了正确的值。
容器注册表,gitlab实例和运行程序都在同一ubuntu服务器上。
如果我尝试从我的PC或通过运行该作业的服务器在作业中使用命令登录,则连接成功。
亚军的配置:
[[runners]]
name = "Smooth"
url = "https://git.exemple.fr"
token = "a5e28f2c95cf5ff887edb535f80e37"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker:stable"
privileged = true
disable_cache = false
volumes = ["/cache"]
shm_size = 0
[runners.cache]
最佳答案
起初我以为这个问题与cloudflare DNS的使用有关,但实际上是因为我在ubuntu服务器上启用了ufw(不复杂的防火墙),该服务器在子域下为gitlab实例和gitlab容器注册表提供服务。解决方案很简单:
sudo ufw allow [port]
其中
[port]
是gitlab容器注册表使用的端口虽然我不明白为什么我可以从笔记本电脑或服务器中获得uft问题的
docker login
,但没有CI作业的原因
关于docker - 登录gitlab ci中的gitlab容器注册表时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52457862/