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_net2docker 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 powershellC:\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