GitLab Runner: "Could not resolve host", but can with exec into container

Viewed 350

I'm trying to get GitLab set up with docker compose. I've got GitLab and a Runner working, but when a pipeline runs, it fails to clone the 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

However, when I exec into the container, I can:

$ 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.

So everything looks fine from the container, I suppose GitLab must be doing something I'm not expecting when it actually runs it - any ideas?

The host is Ubuntu 16.04, my compose file is:

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 Answers
Related