{"id":8651,"date":"2017-03-31T09:20:27","date_gmt":"2017-03-31T09:20:27","guid":{"rendered":"http:\/\/fluentbytes.com\/?p=8651"},"modified":"2017-03-31T09:20:27","modified_gmt":"2017-03-31T09:20:27","slug":"how-to-work-around-docker-compose-dns-issue-with-docker-on-windows","status":"publish","type":"post","link":"https:\/\/fluentbytes.com\/?p=8651","title":{"rendered":"How to work around docker-compose DNS issue with docker on windows"},"content":{"rendered":"<p>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.<\/p>\n<p>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:<\/p>\n<p><!--more--><\/p>\n<pre class=\"theme:vs2012 lang:yaml decode:true \">version: \"2.1\"\nservices:\nweb:\n\u00a0 build: .\/web\n\u00a0 expose:\n\u00a0\u00a0 - \"80\"\n\u00a0 depends_on:\n\u00a0\u00a0 - db\n\u00a0 tty:\n\u00a0\u00a0\u00a0 true\ndb:\n\u00a0 build: .\/db\n\u00a0 expose:\n\u00a0\u00a0 - \"1433\"\n\u00a0 environment:\n\u00a0\u00a0\u00a0 - \"ACCEPT_EULA='Y'\"\n\u00a0 tty:\n\u00a0\u00a0\u00a0 true\nnetworks:\n\u00a0 default:\n\u00a0\u00a0\u00a0 external:\n\u00a0\u00a0\u00a0\u00a0\u00a0 name: \"nat\"<\/pre>\n<p>Based on this compose file the web tier should be able to resolve the database by the network name <strong>db<\/strong> and the <strong>db<\/strong> should be able to resolve the web tier by the name <strong>web<\/strong>.<\/p>\n<p>Unfortunately at the moment there is a bug that should be fixed soon. the work around this at the moment is as follows:<\/p>\n<p>in the docker files where you build your containers, you need to add the following statement:<\/p>\n<pre class=\"theme:vs2012 toolbar-overlay:false lang:default decode:true\">#FIX DNS issues currently in Windows Containers\nRUN powershell set-itemproperty -path 'HKLM:\\SYSTEM\\CurrentControlSet\\Services\\Dnscache\\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord<\/pre>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>Hopefully this will be fixed soon, but in the meanwhile this can help you make things work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":8681,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[4],"tags":[19,20,21,26],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/fluentbytes.com\/wp-content\/uploads\/2017\/03\/dockerandwindows-50.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/fluentbytes.com\/index.php?rest_route=\/wp\/v2\/posts\/8651"}],"collection":[{"href":"https:\/\/fluentbytes.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fluentbytes.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fluentbytes.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/fluentbytes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8651"}],"version-history":[{"count":0,"href":"https:\/\/fluentbytes.com\/index.php?rest_route=\/wp\/v2\/posts\/8651\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fluentbytes.com\/index.php?rest_route=\/wp\/v2\/media\/8681"}],"wp:attachment":[{"href":"https:\/\/fluentbytes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fluentbytes.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fluentbytes.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}