2

How can I connect my GitLab installation with a runner, that are both running in separate docker containers?

GitLab is working fine, it is reachable via http://docker.lcnet:8181

My first problem is, where can I find my Gitlab "CI" URL? or is it just my normal URL? Do I have to inlcude the Port?

I'm using this doc: https://docs.gitlab.com/ce/ci/docker/using_docker_images.html

This is what I get:

ubuntu@docker:~$ sudo docker exec -it gitlab-runner gitlab-runner register

Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://docker.lcnet:8181
Please enter the gitlab-ci token for this runner:
<token from settings>
Please enter the gitlab-ci description for this runner:
[5bf3c5086904]: my-runner
Please enter the gitlab-ci tags for this runner (comma separated):
tag1
ERROR: Registering runner... failed runner=hm-eFuar status=couldn't execute POST against http://docker.lcnet:8181/ci/api/v1/runners/register.json:                                                                      Post http://docker.lcnet:8181/ci/api/v1/runners/register.json: dial tcp: lookup vader.nts on 8.8.8.8:53: no such host
PANIC: Failed to register this runner. Perhaps you are having network problems

I see that there are network problems but after some hours of searching I couldn't find a decent hint to resolve this problem. I know that docker images can communicate with each other via docker-names but this isn't mentioned anywhere how to set this up.

I tried to enter "gitlab-ce" (which is the name of the docker container running gitlab) but it won't work.

Do I have to create a docker network?

G-M
  • 61
  • 1
  • 5

3 Answers3

4

Ok so after diving into docker more deeply, I understood that I have to link the runner-container to the GitLab container with "link".

This is something that is missing in the docs above. Although it says that running Gitlab and a runner on the same machine isn't suggested (which I guess would also solve the problem), in some scenarios it is needed, so it would be nice to mention that the containers have to be linked:

$ docker run -d -P --name gitlabce gitlab/gitlab-ce:latest
$ docker run -d -P --name runner --link gitlabce:gitlabce gitlab/gitlab-runner:latest

$ docker exec -it runner gitlab-runner register
Running in system-mode.                                                                                                                                                                                                                                       

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):                                                                                                                                                                                        
http://gitlabce  

Please enter the gitlab-ci token for this runner:                                                                                                                                                                                                             
(your token from gitlab->admin->runner) 

Please enter the gitlab-ci description for this runner:                                                                                                                                                                                                       
[a11fa3f389d9]:    

Please enter the gitlab-ci tags for this runner (comma separated):                                                                                                                                                                                            

Registering runner... succeeded                

I'm new to docker so sorry for this trivial question, but maybe it will help others.

Another method would be to create a user defined network, since, if I understood correctly, containers can communicate with each other without links.

G-M
  • 61
  • 1
  • 5
0

In my case, I had to point to my network bridge IP address and it worked.

I saw the network of gitlab with the following:

$docker container inspect $id

Then when I register I put the gitlab IP address from network bridge

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):                                                                                                                                                                                        
http://$ip
kenlukas
  • 3,101
  • 2
  • 16
  • 26
0

In your case I would expose 8181 on the Docker host. This way they can communicate on the Docker host's external IP. This command should register the Runner (update the token and the IP in it):

docker exec gitlab-runner gitlab-runner register --non-interactive --name "docker-runner-1" --url "http://docker.lcnet:8181" --registration-token <token> --docker-image="docker:17.03.1-ce" --docker-extra-hosts="docker.lcnet:<the external IP of the host>" --executor=docker --docker-volumes /var/run/docker.sock:/var/run/docker.sock
Balint Bako
  • 101
  • 2