I'd like to run a Gitlab instance and a Gitlab runner (for CI/CD) on one server.
I'm using an NGINX container to proxy the requests to the machine together with a letsencrypt-helper container to auto-generate the letsencrypt ssl certificates based on the virtual hosts in the proxy (for details see https://github.com/nginx-proxy/nginx-proxy and http://jasonwilder.com/blog/2014/03/25/automated-nginx-reverse-proxy-for-docker/).
However, after sucessfully installing Gitlab and after reading through the Gitlab docs and successfully registering the runner with the Gitlab instance, the runner always gets the following error message when I try to run any pipeline:
[...]
Reinitialized existing Git repository in /builds/group1/test_project/.git/
fatal: unable to access 'http://gitlab.mydomain.com/group1/test_project.git/': SSL certificate problem: unable to get local issuer certificate
ERROR: Job failed: exit code 1
Connecting to the runner container (using docker exec -it gitlab_runner /bin/sh since it's an alpine container) and trying the connection shows a connection problem:
curl https://gitlab.mydomain.com
curl: (7) Failed to connect to gitlab.mydomain.com port 443 after 0 ms: Connection refused
The other main Gitlab container is visible from the runner's container (I can resolve it to IP, ping it...) but it seems access to port 443 it not possible. This is very confusing, the "expose"-directive (see below) should enable that access.
I have noticed that the pipeline error message and the curl error message are not exactly the same (one decries a property of the certificate and the other the connection itself), but maybe they have the same reason.
What am I missing, how can I have a Gitab runner in a container parallel to a Gitlab instance?
This is the setup / compose file:
docker-compose.yml
version: '3.6'
services:
gitlab:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab
restart: unless-stopped
hostname: 'gitlab.mydomain.com'
environment:
- VIRTUAL_HOST=gitlab.modapell.ch
- LETSENCRYPT_HOST=gitlab.modapell.ch
- external_url='https://gitlab.modapell.ch'
# Cannot use the following because it clashes with the previous 2 lines
# GITLAB_OMNIBUS_CONFIG: |
# external_url 'https://gitlab.modapell.ch'
networks:
- prod_net
expose:
- '80'
- '443'
- '22'
volumes:
- $GITLAB_HOME/config/gitlab:/etc/gitlab'
- $GITLAB_HOME/logs:/var/log/gitlab'
- $GITLAB_HOME/data:/var/opt/gitlab'
shm_size: '256m'
gitlab-runner:
image: gitlab/gitlab-runner:alpine
container_name: gitlab-runner
restart: unless-stopped
depends_on:
- gitlab
volumes:
- $GITLAB_HOME/config/gitlab-runner:/etc/gitlab-runner
- /var/run/docker.sock:/var/run/docker.sock
networks:
- prod_net
networks:
prod_net:
name: prod_net
external: true