Answers: <p>Create a Transparent Network: This should allow the containers to directly connect to the physical network of the host.</p>
  <pre class="lang-bash prettyprint-override"><code>docker network create -d transparent --subnet=12.123.123.0/24 --gateway=12.123.123.1 test_net2
  </code></pre>
  <p>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.</p>
  <pre class="lang-bash prettyprint-override"><code>docker run --network=test_net2 --ip=12.123.123.17 -it --name dedicated_ip_container mcr.microsoft.com/windows/servercore:ltsc2022 powershell
  
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2024-04-27T14:54:19.000Z
Answers: 2024-04-27T14:58:03.167Z
Answers: 2024-04-27T14:58:03.167Z
Answers: user45105
Body: <p>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 <strong>-p 8080:8080</strong>.</p>
  <p>Many answers to this mention <code>macvlan</code> or <code>ipvlan</code>, but they are available to network drivers only for Linux.</p>
  <p>Here my supposed dedicated IP that I want to assign to the container is 12.123.123.17.</p>
  <p>Tried this:</p>
  <pre><code>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
  </code></pre>
  <p>also tried without</p>
  <pre><code>-o com.docker.network.windowsshim.enable_outboundnat=true
  </code></pre>
  <p>besides <strong>transparent</strong> I also tried <strong>nat</strong> and <strong>l2bridge</strong></p>
  <p><code>-d nat</code> 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.</p>
  <p>The option to link directly to the host IP also doesn't work</p>
  <pre><code>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.
  </code></pre>
  <p>Docker version 26.0.0, build 2ae903e</p>
  
Comments: CC BY-SA 4.0
Comments: 2024-03-28T12:54:00.327Z
Comments: Don't windows firewall rules help in this case?
Comments: George Udosen
Comments: CC BY-SA 4.0
Comments: 2024-03-28T14:05:47.200Z
Comments: could you provide the required commands ?
Comments: Vadim
Tags: <docker><networking><windows><ip>
Title: Bind dedicated ip to docker container in Windows Server 2022
UserDisplayName: Vadim
ThreadText: # Bind dedicated ip to docker container in Windows Server 2022
  
  (Asked by: username_0 on 2024-03-28)
  
  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
  
  **Tags:** docker, networking, windows, ip
  
  > **Comments:**
  > **username_1**: Don't windows firewall rules help in this case?  
  > **username_0**: could you provide the required commands ?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2024-04-27. Score: 0
  
  Create a Transparent Network: This should allow the containers to directly connect to the physical network of the host.
  
  ```bash
  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.
  
  ```bash
  docker run --network=test_net2 --ip=12.123.123.17 -it --name dedicated_ip_container mcr.microsoft.com/windows/servercore:ltsc2022 powershell
  
  ```
  
  
  ---
  
  