Using a custom address space with a Container NAT network
Learn how a custom address space can be used with a NAT network.
August 25, 2016
Q. How can I use my own address space for a NAT network with Windows containers?
A. A default NAT network is created when the Docker daemon starts and with the RTM of Windows Server 2016 only a single NAT network can exist because only one instance of WinNAT is supported on a host that enables the NAT network to function.
There are two options if you don't wish to use the default 172.16.0.0/12 address space the NAT network uses (for example if you use that address space in your normal network).
The first option is to change the address space used by the default NAT network.
Stop the docker daemon
stop-service dockerRemove the default network
Get-ContainerNetwork | Remove-ContainerNetworkEnsure the default switch and WinNAT instance are gone by running Get-VMSwitch and Get-NetNat.
Edit the daemon.json file in folder C:ProgramDatadockerconfig or if it does not exist create the file. For more information on docker configuration see https://msdn.microsoft.com/en-us/virtualization/windowscontainers/docker/configure_docker_daemon.
In the file add the following JSON but change to match the IP range you wish to use
{
"fixed-cidr": "192.168.1.0/24"
}Restart docker
start-service docker
The other option is to tell the Docker daemon to not create the default NAT network at all by repeating the steps above but in step 5 the content to be added is:
{
"bridge": "none"
}
Now create your own NAT network with the address space you want (note when starting a docker instance you will have to specify which network it will connect to manually):
docker network create -d nat --subnet=192.168.1.0/24 NatNetwork1
About the Author
You May Also Like