Reputation: 1724
If I start a docker container, I can for some reason access the docker host's services if I use the host's LAN ip, eg:
docker run -it ubuntu sh -c "apt-get update && apt-get install -y netcat && nc -z 192.168.196.135 3449"
But how do I know which IP to access the host on? Running ifconfig
doesn't show any networks in the 192.x
range. What if the host is disconnected from the LAN?
Upvotes: 0
Views: 318
Reputation: 2257
You can add a entry to your container's /etc/hosts
docker run --add-host="dockerhost:192.168.196.135" -it ubuntu sh -c "apt-get update && apt-get install -y netcat && nc -z dockerhost 3449"
You also can use this docker discovery agent
If you need something more sophisticated then that you'll need a service discovery system like zookeeper.
Upvotes: 1