从Docker 19.03.15更新到20.10.5后,内部网络中断



我使用下面的docker-compose.yml来运行一个带有一个runner的dockerized GitLab实例。两者都在同一网络中。(网桥名称是显式设置的,因为防火墙规则依赖于它。(

version: '3.9'
services:
web:
image: 'gitlab/gitlab-ce:latest'
restart: 'unless-stopped'
hostname: 'gitlab.example.com'
ports:
- '8080:80'
- '8022:22'
environment:
[...]
volumes:
[...]
runner:
image: 'gitlab/gitlab-runner:alpine'
restart: 'unless-stopped'
hostname: 'gitlab-runner.example.com'
depends_on:
- 'web'
environment:
[...]
volumes:
[...]
networks:
default:
driver: 'bridge'
ipam:
driver: 'default'
config:
- subnet: '172.16.1.0/24'
driver_opts:
com.docker.network.bridge.name: 'br-gitlab'

这在Docker 19.03.15上运行良好,但在升级到20.10.5后,runner无法再从它提取源代码的位置连接到web。从CCD_ 3内部的Bash手动地执行同样的操作;连接被拒绝":

$ curl https://gitlab.example.com/user/repo.git/
Connecting to gitlab.example.com (172.16.1.2:443)
wget: can't connect to remote host (172.16.1.2): Connection refused

runner容器中有网络,我可以访问其他站点并解析域名。显然,它与(主机上的(iptables无关,关闭这些防火墙后问题仍然存在。

我已经查看了Docker的更改日志,但没有看到任何解释这一点的更改。知道我在这里没看到什么吗?

谢谢!

想好了:

我的设置导致runner从gitlab.example.com:443获取源,gitlab.exexample.com:443是主机上Nginx代理提供的端口。这在Docker 19上起作用,但是,从Docker 20开始,runner容器就不能再通过主机连接了。这完全可以,解决方案是:告诉runner在克隆源时直接联系web中的GitLab服务器。config.toml中的每个转轮必须包含:

url = "http://172.16.1.2:8080/"
clone_url = "http://172.16.1.2:8080/"         # <- this one was missing

最新更新