0

I have a Windows server 2022 host and on it, I launched a docker container running the same Windows server core OS. This server has 2 IPs attached to it and I want one of them to be assigned only to one of my containers. Container has an app running on port 8080, on container creation I used -p 8080:8080.

Many answers to this mention macvlan or ipvlan, but they are available to network drivers only for Linux.

Here my supposed dedicated IP that I want to assign to the container is 12.123.123.17.

Tried this:

docker network create --gateway 12.123.123.1 --subnet 12.123.123.0/24 -d transparent -o com.docker.network.windowsshim.enable_outboundnat=true test_net2

docker network connect --ip 12.123.123.17 test_net2 epic_rosalind

also tried without

-o com.docker.network.windowsshim.enable_outboundnat=true

besides transparent I also tried nat and l2bridge

-d nat worked and I could access my container app through a dedicated IP, it's just that I could also access other containers, but I need this IP to be tied only to one container.

The option to link directly to the host IP also doesn't work

docker run -p 12.123.123.17:8080:8080 --name cont_v1  mcr.microsoft.com/windows/servercore:ltsc2022 -it powershell

C:\Program Files\Docker\docker.exe: Error response from daemon: failed to create endpoint cont_v3 on network nat: Windows does not support host IP addresses in NAT settings.

Docker version 26.0.0, build 2ae903e

2
  • Don't windows firewall rules help in this case? Commented Mar 28 at 12:54
  • could you provide the required commands ?
    – Vadim
    Commented Mar 28 at 14:05

1 Answer 1

0

Create a Transparent Network: This should allow the containers to directly connect to the physical network of the host.

docker network create -d transparent --subnet=12.123.123.0/24 --gateway=12.123.123.1 test_net2

Run the Container with Specific IP: Since you need to assign a specific IP, make sure the container is connected to the transparent network and assigned the specific IP.

docker run --network=test_net2 --ip=12.123.123.17 -it --name dedicated_ip_container mcr.microsoft.com/windows/servercore:ltsc2022 powershell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.