lqshow / notes

Cheat Sheet
10 stars 2 forks source link

Gitlab-CI: Failed to connect to gitlab.basebit.ai port 80: Connection refused #28

Closed lqshow closed 6 years ago

lqshow commented 6 years ago

原因

在gitlab中运行pipeline失败

job logs

Running with gitlab-runner 10.5.0 (80b03db9)
  on my-runner f7b5348d
Using Docker executor with image node:latest ...
Pulling docker image node:latest ...
Using docker image sha256:29831ba76d9371cece19db2fd3bed889eb471a4a5d6634102011cb1105a8e167 for node:latest ...
Running on runner-f7b5348d-project-1-concurrent-0 via d69fbb17862b...
Cloning repository...
Cloning into '/builds/dev/hello-world'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@gitlab.basebit.ai/dev/hello-world.git/': Failed to connect to gitlab.basebit.ai port 80: Connection refused
ERROR: Job failed: exit code 1

容器列表

  1. gitlab docker
  2. gitlab runner docker
docker run -d --name docker-gitlab-runner --restart always \
  --link docker-gitlab:gitlab.basebit.ai \
  -v ~/workspace/docker/gitlab-runner/config:/etc/gitlab-runner \
  -v /var/run/docker.sock:/var/run/docker.sock \
  gitlab/gitlab-runner:latest

解决方案

vi ~/workspace/docker/gitlab-runner/config/config.toml

[runners.docker]
     extra_hosts = ["gitlab.basebit.ai:172.17.0.2"]
[[runners]]
  name = "hello-world-runner"
  url = "http://gitlab.basebit.ai/"
  token = "9dcf6772e3b1bd8042ec04c40f56e5"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "alpine:latest"
    privileged = false
    disable_cache = false
    volumes = ["/cache"]
    extra_hosts = ["gitlab.basebit.ai:172.17.0.2"]
    shm_size = 0
  [runners.cache]

参考

TaylorPzreal commented 3 years ago

主要是配置host映射 extra_hosts = ["gitlab.basebit.ai:172.17.0.2"] 将私有域名映射到主机ip