I have recently been researching NetflixOSS and found Netflix provides many Docker images that make setting up a local development environment really easy. In order to run the images on Windows, I installed Docker for Windows which is a Hyper-V based Docker host for Windows. This all installed without issue and I was able to run the NetflixOSS images:
The problem is you can’t access the service websites from the Docker for Windows host.
Docker for Windows creates a private network for itself in Hyper-V. Both the Docker host and containers are issued IPs in this private network. By default, the computer running Docker for Windows cannot access this private network. After several days a digging I found a forum post which describes how to open a route between the private network and the host OS by running the following command from an elevated command prompt:
route add 172.17.0.0 mask 255.255.0.0 10.0.75.2 -p
The first IP address (172.17.0.0) is a reference to the default Docker subnet. The mask specifies the level at which you want IPs routed. The last IP is the address for the Docker host. You can find this by opening Hyper-V Manager, selecting the MobyLinuxVM virtual machine and viewing the Networking tab at the bottom of the window. The –p flag specifies the route should persist across reboots of the machine.
After adding the route, you can run route print to see it was added correctly:
If you set the IPs correctly, the Docker container should now be accessible from a browser on your development machine. Note I have noticed it can take a minute or two for the site to resolve the first time.
I hope this post was helpful. I will be digging into Docker and NetflixOSS with .NET Core in the future so stay tuned for more related posts.
Pingback: Selenium with .NET Core – dotnet catch
Pingback: Access a Linux Docker Container From the Windows Docker-Host Host using Port Publishing (–P) – dotnet catch
Pingback: ASP.NET Core with Docker Container | Ryan Yong