How to assign multiple static IPs to docker container
Asked Answered
B

2

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.

Bancroft answered 16/1, 2018 at 17:42 Comment(0)
G
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.

Genni answered 26/2, 2018 at 21:47 Comment(3)
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.Bancroft
@Bancroft " maintenance becomes very hard": not necessarily: github.com/jwilder/nginx-proxyGenni
@Bancroft In the same idea: traefik: github.com/containous/traefik (medium.com/@lukastosic/…)Genni
B
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

Bancroft answered 5/3, 2018 at 22:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.