I know this could be taken as a duplicate but I have tried everything I have found on the internet with no success.
I'm trying to set up a local gitlab-ce server on Windows using the Docker Desktop, but I'm not experienced enough to solve this error. I'm probably not understanding the situation very well.
I installed gitlab runner and registered it via Docker Compose. Here's the file:
services:
dind:
container_name: dind
image: docker:25.0.3-dind
restart: unless-stopped
privileged: true
environment:
DOCKER_TLS_CERTDIR: ""
command:
- --storage-driver=overlay2
networks:
- playground
volumes:
- D:/Playground/data/gitlab-runner/dind:/var/lib/docker
runner:
container_name: runner
image: gitlab/gitlab-runner:alpine-v16.9.0
restart: unless-stopped
environment:
- DOCKER_HOST=tcp://dind:2375
networks:
- playground
volumes:
- D:/Playground/conf/gitlab-runner:/etc/gitlab-runner:z
register-runner:
container_name: registerrunner
image: gitlab/gitlab-runner:alpine-v16.9.0
restart: 'no'
depends_on:
- dind
environment:
- CI_SERVER_URL=http://gitlab.playground.local/
- RUNNER_TOKEN=...
command:
- register
- --non-interactive
- --url=http://gitlab.playground.local/
- --token=...
- --name=Runner
- --executor=docker
- --docker-image=docker:25.0.3-dind
- --docker-volumes=/var/run/docker.sock:/var/run/docker.sock
networks:
- playground
volumes:
- D:/Playground/conf/gitlab-runner:/etc/gitlab-runner:z
- D:/Playground/data/gitlab-runner/dind:/var/lib/docker
networks:
playground:
name: playground
driver: bridge
And my config.toml:
concurrent = 1
check_interval = 0
log_level = "debug"
log_format = "text"
connection_max_age = "15m0s"
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Runner"
url = "http://gitlab.playground.local/"
id = 34
token = "..."
token_obtained_at = 2024-02-22T03:30:08Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker"
[runners.cache]
MaxUploadedArchiveSize = 0
[runners.docker]
host = "tcp://dind:2375"
tls_verify = false
image = "docker:25.0.3-dind"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
cache_dir = "cache"
shm_size = 0
network_mtu = 0
The http://gitlab.playground.local is conveniently defined in the Windows host file and I can access the instance. The problem is with the runner.
I can see the active runner in my gitlab instance, but when I run the pipeline I constantly get the following error:
ERROR: Failed to remove network for build
ERROR: Preparation failed: Cannot connect to the Docker daemon at tcp://dind:2375. Is the docker daemon running? (docker.go:933:12s)
I've already exposed the daemon on tcp://localhost:2375 without TLS in Docker, as I have seen in other threads with similar problems, but nothing changed.
Edit: more info added below
I've basically played a lot of trial and error up to the current setup. Among other things, I already tried not to use Docker-in-Docker and reduce the complexity, but I also got an exception.
I also tried to cover permissions using usermod -aG docker gitlab-runner, but alpine doesn't have the usermod command, so I added the attribute user: 2000:2000 in the docker compose file as suggested here, but again without success.
I really believe (it's more of a hope than a certainty) that my configuration is not far from correct, but there is something that escapes me and I don't know what it is.
What am I missing?