Connect GitLab and Gitlab runner, both in Docker

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.

Tags:

Docker

Gitlab