Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lqshow opened this issue Feb 26, 2018 · 1 comment

Comments

@lqshow
Copy link
Owner

lqshow commented Feb 26, 2018

原因

在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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants