GitLab Runner:“无法解析主机”,但可以通过exec进入容器

时间:2019-10-17 19:04:05

标签: git docker gitlab gitlab-ci gitlab-ci-runner

我正在尝试使用docker compose设置GitLab。我已经有了GitLab和Runner,但是当管道运行时,它无法克隆git repo:

Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/jgg/test-project/.git/
fatal: unable to access 'http://gitlab-ci-token:[MASKED]@gitlab/jgg/test-project.git/': Could not resolve host: gitlab

但是,当我执行到容器中时,我可以:

$ docker exec -it gitlabsystem_gitlab-runner_1 bash
root@gitlab-runner:/# git clone http://gitlab/jgg/test-project.git
Cloning into 'test-project'...
Username for 'http://gitlab': jgg
Password for 'http://jgg@gitlab': 
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.

因此,从容器中看一切都很好,我想GitLab在实际运行时一定在做我没想到的事情-有什么想法吗?

主机是Ubuntu 16.04,我的撰写文件是:

version: "2.0"

services:
  gitlab:
    image: gitlab/gitlab-ce:latest
    restart: always
    hostname: gitlab
    ports:
      - "22:22"
      - "80:80"
      - "443:443"
    volumes:
      - /srv/sf/gitlab/logs:/var/log/gitlab
      - /srv/sf/gitlab/data:/var/opt/gitlab
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab/'

  gitlab-runner:
    image: gitlab/gitlab-runner:latest
    restart: always
    hostname: gitlab-runner
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

0 个答案:

没有答案