有的時(shí)候我們會(huì)遇到這么一個(gè)問(wèn)題,gitlab 的ci 跑不了了唇跨。 原因是runner全都不活躍了 —— 翻譯成人話稠通,runner按鈕全都灰了,這個(gè)時(shí)候怎么辦呢
故障排查
- 進(jìn)container
docker exec -it gitlab-runner
- 查看runners的狀態(tài)
root@7cffd231aff6:/# gitlab-runner status gitlab-runner: Service is not running.
- 重啟runners
root@7cffd231aff6:/# gitlab-runner run Starting multi-runner from /etc/gitlab-runner/config.toml ... builds=0 Running in system-mode. Configuration loaded builds=0 Metrics server disabled WARNING: Checking for jobs... failed runner=1c7783cc status=couldn't execute POST against http://gitlab.xx.com/api/v4/jobs/request: Post http://gitlab.xx.com/api/v4/jobs/request: dial tcp: i/o timeout
- 發(fā)現(xiàn)可能是 runner 這臺(tái)服務(wù)器連不上 gitlab.xx.com 了买猖, 經(jīng)驗(yàn)證果然是這個(gè)問(wèn)題
gitlab-runner# ping git.jd.com ping: unknown host git.jd.com
解決方案
初步判斷是docker container 訪問(wèn)不了外部網(wǎng)絡(luò)
- docker container 網(wǎng)絡(luò)訪問(wèn)的幾種方式
- bridge: 默認(rèn)模式
- host: 與宿主機(jī)共享IP和端口
- container: 共享其他container的網(wǎng)絡(luò)
- none: 不聯(lián)網(wǎng)
- 驗(yàn)證其他container是否能夠正常訪問(wèn)
- 拉取一個(gè) hello-world image
gitlab-runner# docker run -it hello-world Unable to find image 'hello-world:latest' locally Trying to pull repository docker.io/library/hello-world ... latest: Pulling from docker.io/library/hello-world 9db2ca6ccae0: Pull complete Digest: sha256:135a30bd414bd8d23e386763e36f3dc4ee8ed25d2d6068082c0af796513d9d0d Status: Downloaded newer image for docker.io/hello-world:latest WARNING: IPv4 forwarding is disabled. Networking will not work.
- bingo 服務(wù)器上的 ip_forward 被限制無(wú)法訪問(wèn)
- 拉取一個(gè) hello-world image
- 設(shè)置 ip_forward=1
sysctl -w net.ipv4.ip_forward=1