I just started to explore GitLab as Administrator (previously used it as developer only) to figure out how to setup gitlab with runners. To accomplish this, I decided to setup 2 containers on my local machine (GitLab Instance and Runner) via docker compose and it worked fine until I tried to run my job.
Problem: job (
runner container) can’t see localhost hosted git repo
Docker compose YAML:
version: '3.6' services: instance: image: 'gitlab/gitlab-ee:latest' restart: always networks: - gitlab-network environment: GITLAB_OMNIBUS_CONFIG: | external_url 'http://localhost:8929' gitlab_rails['gitlab_shell_ssh_port'] = 2224 ports: - '8929:8929' - '2224:22' volumes: - '$GITLAB_HOME/config:/etc/gitlab' - '$GITLAB_HOME/logs:/var/log/gitlab' - '$GITLAB_HOME/data:/var/opt/gitlab' shm_size: '256m' runner: image: 'gitlab/gitlab-runner:latest' restart: always networks: - gitlab-network volumes: - '/srv/gitlab-runner/config:/etc/gitlab-runner' - '/var/run/docker.sock:/var/run/docker.sock' command: - 'run' - '--user=gitlab-runner' - '--working-directory=/home/gitlab-runner' networks: gitlab-network: driver: bridge
I can access repo from
runner container using docker bridge name:
But I don’t know how to make
runner container see it as:
I found similar problem with unclear self-answer using
extra_hosts field in config, so I tried different variations of
extra_hosts = ["localhost:instance"], but noting worked so I’m here to ask for help.
config.toml of my
concurrent = 1 check_interval = 0 shutdown_timeout = 0 [session_server] session_timeout = 1800 [[runners]] name = "style_checker" url = "http://instance:8929" id = 4 token = "glrt-vst16ksxgXLPe7ozeS-r" token_obtained_at = 2023-07-04T09:54:01Z token_expires_at = 0001-01-01T00:00:00Z executor = "docker" [runners.cache] MaxUploadedArchiveSize = 0 [runners.docker] tls_verify = false image = "python:latest" privileged = false disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0