6

I am able to run a docker container and assign one static IP using this command

docker run -it --name container1--net ProdNetwork --ip 10.1.1.100 centos:latest /bin/bash

I couldn't figure out how to assign multiple static IP's to one container, can someone help.

user1550159
  • 1,197
  • 3
  • 19
  • 36

2 Answers2

0

That was requested before.

One possible solution/woraround is to deploy 3 containers:

  • 2 NGiNX containers, each with their own static IP, reverse-proxying to the third container (see "nginx redirect to docker container")
  • your third container, with its own internal private IP with a swarm network, which will receive the queries addressed to one of the two other NGiNX containers.

This might be more straightforward than trying to add another network route to a given container.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank Von, i saw nginix work around, but my secnario is to HOST at least 15 SSL sites on windows container.Routing through reverse proxy to that many sites is complex and maintenance becomes very hard. – user1550159 Feb 26 '18 at 21:57
  • 1
    @user1550159 " maintenance becomes very hard": not necessarily: https://github.com/jwilder/nginx-proxy – VonC Feb 26 '18 at 21:58
  • @user1550159 In the same idea: traefik: https://github.com/containous/traefik (https://medium.com/@lukastosic/traefik-docker-reverse-proxy-and-much-much-more-a39b24b9d959) – VonC Feb 26 '18 at 21:59
0

Spin a new windows container (I used nano server) and run the following command in the container shell to add multiple static addresses:

New-NetIPAddress –InterfaceIndex 2 –IPAddress 172.31.2.3 -PrefixLength 24

Reference:

https://forums.docker.com/t/how-to-host-multiple-websites-with-different-ip-s-in-iis-container/46985/4

robinCTS
  • 5,746
  • 14
  • 30
  • 37
user1550159
  • 1,197
  • 3
  • 19
  • 36