I have a the repo with test CI pipeline, which is the following:
# .gitlab-ci.yml
image:
name: gcc
build:
stage: build
script:
- echo 123
And it fails:
Running with gitlab-runner 14.3.1 (8b63c432)
on 61f761c24d2a 6sxYm825
Preparing the "docker" executor
00:05
Using Docker executor with image gcc ...
Pulling docker image gcc ...
Using docker image sha256:f323b5207c6c929853380a3bfa268c899d8f0120f4364768af24dae31e92c279 for gcc with digest gcc@sha256:1b0593e75693f0f2480910b33b02119f6ad891a5a02a61a6e293ad09c8c3eef1 ...
Preparing environment
00:01
Running on runner-6sxym825-project-2-concurrent-0 via da14575dda62...
Getting source from Git repository
00:00
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/root/project/.git/
fatal: unable to access 'http://gitlab/root/project.git/': Could not resolve host: gitlab
ERROR: Job failed: exit code 1
Seems like docker container, which runs on the gcc image could not resolve the host because it runs inside another docker. How can the host be resolved? Looks like i need to somehow add the docker to the docker-compose network or somehow tell it what is http://gitlab/ actually is.
I changed external url /etc/gitlab/gitlab.rb
## GitLab URL
##! URL on which GitLab will be reachable.
##! For more details on configuring external_url see:
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
##!
##! Note: During installation/upgrades, the value of the environment variable
##! EXTERNAL_URL will be used to populate/replace this value.
##! On AWS EC2 instances, we also attempt to fetch the public hostname/IP
##! address from AWS. For more details, see:
##! https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
external_url 'http://gitlab/'
# /etc/gitlab-runner/config.toml
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "61f761c24d2a"
url = "http://gitlab/"
token = "6sxYm825Sa7mwRwRBpyg"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker:19.03.12"
privileged = true
disable_cache = false
volumes = ["/certs/client", "/cache"]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
# docker-compose.yml
version: '3.5'
services:
gitlab:
image: gitlab/gitlab-ce:latest
hostname: gitlab
container_name: gitlab
restart: unless-stopped
environment:
GITLAB_OMNIBUS_CONFIG: |
gitlab_rails['gitlab_shell_ssh_port'] = 8822
ports:
- "8000:80"
- "8822:22"
volumes:
- ./config/gitlab:/etc/gitlab
- ./data/gitlab:/var/opt/gitlab
- ./logs:/var/log/gitlab
networks:
- gitlab
gitlab-runner:
image: gitlab/gitlab-runner
container_name: runner
restart: unless-stopped
depends_on:
- gitlab
volumes:
- ./config/gitlab-runner:/etc/gitlab-runner
- /var/run/docker.sock:/var/run/docker.sock
networks:
- gitlab
networks:
gitlab: