Im experimenting with a docker network and I cannot find a way to accomplish the following:
Start a simple netcat server in the host:
nc -l -p 5555
and then exchange data with this server from the docker container, for example
hostip=$(ip route | awk '/docker0/ { print $NF }')
docker run --add-host=docker:"${hostip}" --rm -it hiromasaono/curl curl docker:5555
The curl request just hangs, and the host netcat server does not receive the request.
If I run docker with an option instead --net=host, it works:
docker run --net=host --rm -it hiromasaono/curl curl 127.0.0.1:5555
and netcat server gets
GET / HTTP/1.1
User-Agent: curl/7.35.0
Host: 127.0.0.1:5555
Accept: */*
How can I connect to a simple host netcat server from a docker container without using --net=host(by default this --net=bridge)?
(fyi: I am running docker / client 1.11.2)
Potentially Relevant Resources I studied searching for an answer: