I would like to network with a child docker container from a parent docker container, with a docker-in-docker setup.
Let\'s say I\'m trying to connect to a simple Apache
Building upon Yuriy's answer:
2) From inside the
docker:latest container, [...] it will be available on whatever hostname is set for thedocker:dindcontainer. In this case, you used--name mydind, thereforecurl mydind:8080[...]
In the Gitlab CI config, you can address the DinD container by the name of its image (in addition to the name of its container, which is auto-generated):
Accessing the services
Let’s say that you need a Wordpress instance to test some API integration with your application.
You can then use for example the tutum/wordpress image in your
.gitlab-ci.yml:services: - tutum/wordpress:latestIf you don’t specify a service alias, when the job is run,
tutum/wordpresswill be started and you will have access to it from your build container under two hostnames to choose from:
tutum-wordpresstutum__wordpress
Using
service:
- docker:dind
will allow you to access that container as docker:8080:
script:
- docker run -d -p 8080:80 httpd:alpine
- curl docker:8080
Edit: If you'd prefer a more explicit host name, you can, as the documentation states, use an alias:
services:
- name: docker:dind
alias: dind-service
and then
script:
- docker run -d -p 8080:80 httpd:alpine
- curl dind-service:8080
Hth, dtk