Connecting GitLab Runner to GitLab in Docker Network

I have successfully followed the instructions on how to setup Omnibus in Docker(with some minor hiccups) but there are errors when I am trying to do the same using docker-compose.yaml.

So I run the following docker-compose.yaml:

version: "3.7"
services:
  gitlab:
    container_name: gitlab
    hostname: 172.18.0.2
    image: gitlab/gitlab-ce:latest
    restart: always
    ports:
      - "22:22"
      - "80:80"
      - "443:443"
    volumes:
      - /srv/gitlab/data:/var/opt/gitlab
      - /srv/gitlab/logs:/var/log/gitlab
      - /srv/gitlab/config:/etc/gitlab
    networks:
      gitlab-network:
        ipv4_address: 172.18.0.2
        aliases:
          - gitlab
  gitlab-runner:
    container_name: gitlab-runner
    image: gitlab/gitlab-runner:latest
    volumes:
      - /srv/gitlab-runner/config:/etc/gitlab-runner
      - /var/run/docker.sock:/var/run/docker.sock
    restart: always
    networks:
      gitlab-network:
        ipv4_address: 172.18.0.3
        aliases:
          - gitlab-runner
networks:
  gitlab-network:
    name: gitlab-network
    driver: bridge
    ipam:
      driver: default
      config:
      -
        subnet: 172.18.0.0/24

And then when trying to register the runner:
docker run --rm -t -i -v /srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner:latest register
...
ERROR: Registering runner... failed                 runner=AexzX9CM status=couldn't execute POST against http://172.18.0.2/api/v4/runners: Post http://172.18.0.2/api/v4/runners: dial tcp 172.18.0.2:80: i/o timeout
PANIC: Failed to register this runner. Perhaps you are having network problems 

I can register if I do it with:
docker exec -it gitlab-runner bash
gitlab-runner register

After which point a runner appears in GitLab. But then running a job ends in:

Running with gitlab-runner 11.8.0 (4745a6f3)
  on The test runner. 3-nqx1mN
Using Docker executor with image python:3.6 ...
Pulling docker image python:3.6 ...
Using docker image sha256:d6b15f660ce8dc9b70ae4fcd5bdcc1edbb580dd2fce087b1762ba3ca64d09fef for python:3.6 ...
Running on runner-3-nqx1mN-project-2-concurrent-0 via 90a49272c62f...
Cloning repository...
Cloning into '/builds/user/python-protobuf-grpc'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@172.18.0.2/user/python-protobuf-grpc.git/': Failed to connect to 172.18.0.2 port 80: Operation timed out
/bin/bash: line 66: cd: /builds/user/python-protobuf-grpc: No such file or directory
ERROR: Job failed: exit code 1

Using the documentation(first, second) only as long as I set --hostname and then register --url to 172.17.0.2(the IP of GitLab container). Even though I have set alias in /etc/hosts on the host itself.

What am I missing?

I guess I lacked patience. Answer in Stackoverflow:

The gitlab-runner register needs an additional flag --network_mode gitlab-network to add the inner container into the custom network.