How can I get gitlab-runner to use a port other than 80 when cloning a repository over HTTP?
I want to run gitlab-ce in one docker container, and gitlab-runner in another docker container, and use yet another docker container to do the actual CI build. The configs etc. are below, but basically the gitlab-runner fails trying to clone the repository because the ports don’t match. The gitlab-ce is configured to listen for HTTP on port 7080 but the runner seems to always assume port 80.
Running with gitlab-runner 13.0.1 (21cb397c)
on docker-runner XXXXX
Preparing the "docker" executor
Using Docker executor with image cicd-sandbox-ci ...
Using locally found image version due to if-not-present pull policy
Using docker image sha256:ec98f57e6adb23af0c106bae1579af72ad441b849b5e25a1339ac4e6306feb4e for cicd-sandbox-ci ...
Preparing environment
Running on runner-xxxxxxx-project-2-concurrent-0 via 9b32f419a8b5...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/dev/cicd-sandbox/.git/
fatal: unable to access 'http://192.168.1.150/dev/cicd-sandbox.git/': Failed to connect to 192.168.1.150 port 80: Connection refused
Uploading artifacts for failed job
ERROR: Job failed: exit code 1
I’m running gitlab-ce version 12.9.3 and gitlab-runner version 13.0.1 as separate docker containers. I’m not using docker compose (but that will be my next big adventure). I’m on macOS Catalina, using Docker Desktop 2.3.0.3.
The gitlab-ce container was started with the following. Note that the port 80 is mapped to 7080. (I’m not using HTTPS for this experiment and I don’t think it matters for this question.)
sudo docker run --detach \
--hostname localhost \
--publish 7443:443 --publish 7080:80 --publish 7022:22 \
--name gitlab \
--restart always \
--volume $GITLAB_HOME/gitlab/config:/etc/gitlab \
--volume $GITLAB_HOME/gitlab/logs:/var/log/gitlab \
--volume $GITLAB_HOME/gitlab/data:/var/opt/gitlab \
gitlab/gitlab-ce:latest
The gitlab.rb is sets external URL to the host IP address…
external_url 'http://192.168.1.150'
The gitlab-runner container was started with the following.
docker run -d --name gitlab-runner --restart always \
-v /Users/Shared/gitlab-runner/config:/etc/gitlab-runner \
-v /var/run/docker.sock:/var/run/docker.sock \
gitlab/gitlab-runner:latest
The gitlab-runner config.toml is as follows. I use the IP address 192.168.1.150 is the host IP which gitlab listens on. The image cicd-sandbox-ci is the image I want to use for the CI.
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "docker-runner"
url = "http://192.168.1.150:7080"
token = "XXXXXXX"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
image = "cicd-sandbox-ci"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
pull_policy = "if-not-present"