Fluent Bytes

"The only source of knowledge is experience" - Albert Einstein-

How to work around docker-compose DNS issue with docker on windows

When you create a new docker image that is part of a container composition that you want to run on one and the same host, you can run into the issue that the independent containers are not able to reach each other via DNS resolving.

So lets assume you have the following compose file where you want the web tier to be able to reach the database tier given the following compose file:

Based on this compose file the web tier should be able to resolve the database by the network name db and the db should be able to resolve the web tier by the name web.

Unfortunately at the moment there is a bug that should be fixed soon. the work around this at the moment is as follows:

in the docker files where you build your containers, you need to add the following statement:

You need to add this line to each container that needs to reach out on the network and find the other container when using the NAT network.

So in case of my example this needs to be added to the Docker file of the web application, since it will go out and try to reach the database.

Hopefully this will be fixed soon, but in the meanwhile this can help you make things work.

CTO at Xpirit, Microsoft Regional Director, Visual studio ALM MVP, Speaker, Pluralsight Author and IT Architect Consultant

1 Comment

  1. Awesome, thank you so much! I’ve been puzzled for the whole day why my containers cannot connect to each other. First they were working, but suddenly everything stopped. You can imagine my reaction since I just had set up the environment in Azure and then this happened.

    Also it might be worth mentioning that I got confirmation from MS that the fix should be included in April’s monthly updates.

Leave a Reply

Your email address will not be published.

*

© 2017 Fluent Bytes

Theme by Anders NorenUp ↑