大网数据广告活动
服务器运维问答

Connect GitLab and Gitlab runner, both in Docker

· 52CE 我爱测

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…

问题原文

原帖链接 · G-M · CC BY-SA 3.0

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 · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。