Docker Community Forums

Share and learn in the Docker community.

Problem with assigning IP to Windows Container


(Ziernheldj) #1

Expected behavior

Installed Windows 2016 Server, installed with the normal steps the windows container role and the environment that you have to download via powershell. Pulled the official Image from the cloud microsoft/… (SQL Express Edition) and tried to create for the Container fixed IP. Adapter Adding doesn´t work and Bridge Mod doesn´t work, Network mode as I know isn´t able on a Windows Container.

Actual behavior

Creating new Adapter with Powershell with Add-VMNetworkAdapter -VMName WINDOCKER -SwitchName nat.

Brings up the error, that the Virtual Machine named WINDOCKER doesn´t exist, even to that you get with hostname exactly that string.

As said, when I tried to create:

docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network

Doesn´t work at all, failure is poping up, that the plugin for bridge could not been found.

Information

Windows 2016 is fully updated and the pulled MSSQL Server from the repository is the newest aviable. Does anyone know maybe a solution?


#2

There is a restriction on windows server 2016: (see Windows Server 2016 Work-arounds at https://docs.microsoft.com/en-us/virtualization/windowscontainers/container-networking/advanced): “new NAT networks must be created under the larger internal NAT networking prefix”

Subnet should be created with prefix 24, don’t forget to specify a gateway.
Example: asume that default nat network is 172.31.64.0/20, you can create a custom nat with:

docker network create -d nat --subnet=172.31.75.0/24 --gateway=172.31.75.1 your-custom-nat-name

Pleas, note that currently, custom nat networks are not usable in Windows Server 2019 after a reboot, as all nat networks are reset by the OS before starting the docker daemon (https://github.com/moby/moby/issues/38358)