Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind dedicated ip to docker container in Windows Server 2022 #551

Closed
ntrappe-msft opened this issue Dec 10, 2024 · 2 comments
Closed

Bind dedicated ip to docker container in Windows Server 2022 #551

ntrappe-msft opened this issue Dec 10, 2024 · 2 comments
Assignees
Labels
Networking Connectivity and network infrastructure question Further information is requested

Comments

@ntrappe-msft
Copy link
Contributor

Important

Migrating Discussions to Issues. All customer inquiries should be in Issues.

Discussed in https://github.com/microsoft/Windows-Containers/discussions/488

Originally posted by vadimen April 25, 2024
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 29.1.0, build 2ae903e

As I understand the new experimental host network feature is made only for linux also. Couldn't launch, it's not very straightforward to install docker desktop in windows server 2022 core.

Copy link

Thank you for creating an Issue. Please note that GitHub is not an official channel for Microsoft support requests. To create an official support request, please open a ticket here. Microsoft and the GitHub Community strive to provide a best effort in answering questions and supporting Issues on GitHub.

@ntrappe-msft ntrappe-msft added question Further information is requested Networking Connectivity and network infrastructure labels Dec 10, 2024
@ntrappe-msft ntrappe-msft added the triage New and needs attention label Dec 10, 2024
@adrianm-msft
Copy link

To assign a specific IP address to a Docker container on Windows, simply use the --ip flag.

Here is an example:
docker run -itd --name=c0 --network=testnet --ip=12.123.123.17 mcr.microsoft.com/windows/servercore:ltsc2022 powershell

@ntrappe-msft ntrappe-msft removed the triage New and needs attention label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Networking Connectivity and network infrastructure question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants