Can't register Gitlab Runner via docker (compose)

Describe your question in as much detail as possible:
I have self-managed Gitlab on my localhost.
I’m trying to register Gitlab Runner through Docker. Here is my docker-compose.yml

version: "3.0"

    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: ''
        external_url ''
        letsencrypt['enable'] = false
        # Add any other gitlab.rb configuration here, each on its own line
      - '80:80'
      - '443:443'
      - '22:22'
      - './export/containers/gitlab/config:/etc/gitlab'
      - './export/containers/gitlab/logs:/var/log/gitlab'
      - './export/containers/gitlab/data:/var/opt/gitlab'
    image: gitlab/gitlab-runner:latest
    container_name: gitlab-runner
    restart: always
      - web
      - ./export/containers/gitlab-runner/config:/etc/gitlab-runner
      - ./export/containers/gitlab-runner/var/run/docker.sock:/var/run/docker.sock
  • What are you seeing, and how does that differ from what you expect to see?
    I use docker run --rm -it -v /my-path/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register and expect the runner to be registered, but I get:
ERROR: Registering runner... failed                 runner=UVjXdea- status=couldn't execute POST against Post dial tcp: lookup on no such host
PANIC: Failed to register the runner. You may be having network problems.

I am interested in this exact same topic. In particular, I would very much like to see a gitlab repo with everything ready to go - just docker-compose up and off to the races.

Special consideration: in my case I want to be able to build projects that involve building and running containers - so docker in docker.

I’ve found a solution. The problem was because of networks. You should create a network in your docker-compose like this:


And assign the containers to this network. Then when you are going to register a runner, use --network=gitlab so all containers will be in the same network. In my case:

run --rm -it --network=gitlab -v /my-path/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register