Share nat network between Docker Containers & Hyper-V VMs?

When Docker runs for the first time, it creates a network called “nat” and a Hyper-V switch called “nat”. I’d like to be able to attach my existing Hyper-V VMs to the “nat” switch and be able to share the network connection with any containers that get created.

The problem is that since the network addresses for the containers are essentially assigned at random, I’m worried that eventually there will be IP address conflict between a container and one of my VMs.

Is there any way to either 1) tell Docker to always assign IP addresses in a certain subnet or 2) to tell Docker to never assign an IP in the subnet of the VMs?

Thanks,
-Ben

Hi,

Have a closer look at the docker networking: https://docs.docker.com/engine/userguide/networking/

Thanks for the reply, @pmario.

I’ve looked at that document before but didn’t find it very helpful since it’s targeted exclusively at Docker on Linux and the networking options that it uses on that operating system (which are quite different from what is used on Windows/Hyper-V). Was there a particular section that you thought might be helpful with regards to my issues with Docker for Windows? If you were going to try to control how Docker chooses subnets on Linux, where would you start?

Thanks,
-Ben

You are right. May be the wrong place to have a look at. I’m not a network guy, so I’d have to use google too.

Microsoft publishes a lot of docker stuff since some time. May be we’d should search there :slight_smile:

A good chance it to look for: docker on windows … and … network

See: “docker ON windows” … it’s different to “docker for windows” …

-m

It seems that a DHCP server is running on this LAN, assigning addresses to their clients. Maybe you can get/set info to configure your settings.