How To Assign A Static IP Address To A Windows Container

In this article, I’ll show you how I assign a Static IP Address to a Windows Server Container running Windows Containers.

Before assigning a static IP address to a Windows Container we have to create a Network that will define the subnet that the container will be located.

Once the Network Is created, all we need to do Is assign the static IP address when creating the Container with Docker.

In the Docker command below, I’ll create a Transparent network with the subnet details the Container needs to be located.

In the example below, I have a 10.1.1.0 network called TransparentNet3 which I’ll use this name when creating the Container.

docker network create -d transparent --subnet=10.1.1.0/24 --gateway=10.1.1.1 TransparentNet3

To verify that the network was created I’ll run

docker network ls

Next, I’ll create a Windows Container with a Static IP Address of 10.1.1.1

docker run -it --name nano03 --network=TransparentNet3 --ip 10.1.1.1 nanoserver/iis

When the Container Is created, I’ll run an IPCONFIG to verify the IP Address

Ipconfig

Related articles:

2 Replies to “How To Assign A Static IP Address To A Windows Container”

Comments are closed.