I would like to connect to the container of the child docker from the parent container of the docker, with the docker installed in the docker.
Let's say I'm trying to connect to a simple Apache httpd server. When I run the httpd container on my host machine, everything works fine:
asnyder:~$ docker run -d -p 8080:80 httpd:alpine
asnyder:~$ curl localhost:8080
<html><body><h1>It works!</h1></body></html>
But when I do the same with installing dockers in docker, I get an error Connection refused:
asnyder:~$ docker run -d --name mydind --privileged docker:dind
asnyder:~$ docker run -it --link mydind:docker docker:latest sh
/
/
curl: (7) Failed to connect to localhost port 8080: Connection refused
I tried a couple of changes with no luck. Interface Indication 0.0.0.0:
asnyder:~$ docker run -d --name mydind --privileged docker:dind
asnyder:~$ docker run -it --link mydind:docker docker:latest sh
/
/
curl: (7) Failed to connect to 0.0.0.0 port 8080: Connection refused
Using host network:
asnyder:~$ docker run -d --name mydind --privileged docker:dind
asnyder:~$ docker run -it --link mydind:docker docker:latest sh
/
/
curl: (7) Failed to connect to localhost port 80: Connection refused
Surprisingly, I could not find any existing articles about this. Does anyone here have an idea?
Thank!
source
share