How to Configure Windows Containers Networking

In this article, I’ll show you how to configure Windows Containers Networking and get your containers talking to the rest of the network.

By default, new Windows Containers are not exposed to rest of the network and only available on the containers Host Containers network.

To make the containers available we need to configure the Docker \ Windows Containers Network to make them available.

As of writing these article, Windows Containers comes with 5 network types and In this article, I’ll cover only two of them which will cover 90% of deployments.

The 5 Networks are:

  • Port Mapping – This the most basic network, where we open a port on the container and In order to access the container we need to use the Container Host IP \ hostname, Problem with this Is that we can only have one Container using the port.
  • Transparent – Most used network, The Containers network Is directly connected to the physical network and we can either use static IP or DHCP, This is the most popular Network Configuration.
  • Overlay – Used with Docker Swarm
  • L2 Bridge – Each Container will use the same network as the Container Host
  • L2 Tunnel – Only available with Microsoft Cloud Stack.

Port Mapping

To get started, I’ll show you how to use the Port Mapping:

In this example, I’ll create a Container with Port 80 and 443 available on the container and they will automatically be available when using them with the Container Host IP

docker run -it --name nano01 -p 80:80 -p 443:443 microsoft/nanoserver cmd

When I access the Host IP I get the Container IIS Page

When I look at the Container I can see that the Port Is open

Transparent

This network configuration will make all Containers available on the physical network once we define the Transparent Network below:

docker network create -d transparent MyTransparentNetwork

Note: When using Transparent network on a Hyper-V container Host we need to enable MACAddressSpoofing

Next, I’ll create a new Container In the Transparent Network with the code below:

docker run -it --name nano04 --network=MyTransparentNetwork nanoserver/iis

To assign Static IP Address use this article.

To view all the Networks, use the code below:

docker network ls

Hand pick article on the topic:

Leave a Reply