Monday, March 13, 2017

Using the Docker Embedded DNS

this is an easy way I just discovered and am noting it here so I don't forget.

to leverage docker's embedded dns, you can setup a custom network and then each container can resolve to each other via the 'name' attribute.

for example;

1. docker network create internaldns
2. docker run --name rmq -p 15672:15672 --net=internaldns -d rabbitmq:management
3. docker run --name httpcontainer -p 8080:8080 --net=internaldns -d scbs/http-rmq

this gives you;
- ability to connect to the host network via bridge
- ability to have httpcontainer look up the rabbitmq container using the dns entry 'rmq'

i love and think weave net is particularly awesome, but if you're just doing dns lookup on 1 docker host, this seems pretty light and easy

No comments:

Post a Comment