Gitlab-ci:Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running?

背景
从上周开始,CI/CD平台间歇性的会构建失败,当时没太注意,对于失败的job 重试就ok了 ,但是这周就直接构建失败了,主要出现在使用dind的时候不能正常使用docker功能。
报错截图
在这里插入图片描述
原因:
由于我们使用的是docker官方的 docker:dind 镜像, 该镜像在18.09+下做了变化
主要是TLS 证书认证这块 , gitlab没有适配这个变化

Starting in 18.09+, the dind variants of this image will automatically generate TLS certificates in the directory specified by the DOCKER_TLS_CERTDIR environment variable.
Warning: in 18.09, this behavior is disabled by default (for compatibility). If you use --network=host, shared network namespaces (as in Kubernetes pods), or otherwise have network access to the container (including containers started within the dind instance via their gateway interface), this is a potential security issue (which can lead to access to the host system, for example). It is recommended to enable TLS by setting the variable to an appropriate value (-e DOCKER_TLS_CERTDIR=/certs or similar). In 19.03+, this behavior is enabled by default.

This means that when the service starts it will try and create the certificates, which Gitlab Runner doesn't seem to accept this.

解决办法
gitlab-ci.yml文件里面添加一句
DOCKER_TLS_CERTDIR: ‘’

variables:
  DOCKER_HOST: tcp://docker:2375/
  DOCKER_DRIVER: overlay2 
  DOCKER_TLS_CERTDIR: ''

官方的issue:
https://gitlab.com/charts/gitlab/issues/1477
https://gitlab.com/gitlab-org/gitlab-runner/issues/4501#per-job

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值