Docker compose `无法访问';XXX';:无法解析主机`Gitlab CI/CD管道
我们将Gitlab托管在只能通过L2TP VPN隧道访问的专用服务器上。域的DNS设置为内部网络中主机的IP,因此显然,没有VPN无法访问。问题在于,当触发Gitlab CI/CD时,作业中会出现错误,日志如下:Docker compose `无法访问';XXX';:无法解析主机`Gitlab CI/CD管道,docker-compose,gitlab,continuous-delivery,Docker Compose,Gitlab,Continuous Delivery,我们将Gitlab托管在只能通过L2TP VPN隧道访问的专用服务器上。域的DNS设置为内部网络中主机的IP,因此显然,没有VPN无法访问。问题在于,当触发Gitlab CI/CD时,作业中会出现错误,日志如下: Fetching changes with git depth set to 50... Reinitialized existing Git repository in /builds/web/XXX/.git/ fatal: unable to access 'https://&l
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/web/XXX/.git/
fatal: unable to access 'https://<our domain>/web/XXX.git/': Could not resolve host: <our domain>
似乎找不到主机的IP。
我甚至不知道从哪里开始诊断这个问题。在托管服务器中,我ping了主机地址,它显示了正确的IP地址。如何修复此问题?此错误是因为主机不是已知的docker 同样的问题也发生在我身上。我已经在
config.toml
docker executor配置下的extra_hosts
参数中添加了域名和域ip
获取您试图添加的主机的ip地址,因为您需要在extra\u hosts
参数中添加主机名和主机ip
在config.toml
中,进行如下更改:
[[runners]]
name=“maven docker”
url=”https:///gitlab/"
token=“MXvXVma55_Kw2o”
执行者=“码头工人”
[跑步者。自定义\u构建\u目录]
[runners.docker]
tls_验证=错误
image=“maven:最新版本”
特权=真
禁用\u入口点\u覆盖=false
oom\u kill\u disable=错误
禁用缓存=false
额外_主机=[“:”]
pull_policy=“从不”
shm_尺寸=0
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[跑步者,定制]
run_exec=“”
然后,使用命令
sudo gitlab runner restart
或gitlab runner restart
重新启动gitlab runner,先生,您是一个救生员。很高兴它有帮助:)
services:
- docker:dind
before_script:
- docker version
- docker-compose --version
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
build:
stage: build
script:
- docker-compose --context remote up -d --build