I've been tearing my hair out for a few days trying to find a solution.
My gitlab runner is unable to connect to git repos with the error: fatal: unable to access 'https://gitlab.com/project.git/': Could not resolve host: gitlab.com
I tried several solutions:
- restart docker: sudo systemctl daemon
- reload creation of a new runner
- changed the docker image
But I think the problem comes from the DNS of my machine (debian ovh) and I don't know how to solve it.
In effect,
my ci cd is:
stages:
- docker
back:docker:
stage: docker
tags:
- wellcov-runner
image: docker:latest
services:
- docker:dind
before_script:
- echo -n $MAIN_REGISTRY_PASSWORD | docker login -u $MAIN_REGISTRY_USER --password-stdin $CI_REGISTRY
variables:
# Pushing into the shared Wellcov container registry (main repository)
IMAGE: $MAIN_REGISTRY/wellcov-back-end:$CI_COMMIT_REF_NAME
cache:
paths:
- target/
script:
- echo "Gitlab CI - Building back-end ${CI_COMMIT_REF_NAME} docker"
- docker build -t $IMAGE . --build-arg MAVEN_IMAGE=$MAVEN_IMAGE --build-arg UBI_IMAGE=$UBI_IMAGE
- docker push $IMAGE
the runner parameters:
concurrent = 1
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "wellcov-runner"
url = "https://gitlab.com/"
id = 22344137
token = "...."
token_obtained_at = 2023-04-01T17:10:09Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
tls_verify = false
image = "ruby:2.7"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
shm_size = 0
I also suspect that the port of the container is not 8093/tcp like that of the service
should I add a dnas rule to iptables or update the container so that it runs on port 8093/tcp
docker service ls :
ID NAME MODE REPLICAS IMAGE
x4lq3jnshtii gitlab_runner replicated 1/1 gitlab/gitlab-runner:latest ***:8093->8093/tcp**
Docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
652d53ee4780 gitlab/gitlab-runner:latest "/usr/bin/dumb-init …" 14 hours ago Up 14 hours gitlab_runner.1.m3wt71h3f5eldppib83j3uvzj
Thanks for your help