Docker Community Forums

Share and learn in the Docker community.

Public static ip for container does weird things


(Mihaicph) #1

Hi,
I am trying to give my container a static ip I have got from a pool of static ip addresses I have so my ip is :

ip: 10.100.50.45
subnet: 255.255.252.0
gateway: 10.100.48.1

so according to this article : https://blog.jessfraz.com/post/ips-for-all-the-things/

I did following :

docker network create --subnet 10.100.50.0/22 --gateway 10.100.48.1 iptastic
docker run --rm -it --net iptastic --ip 10.100.50.45 nginx

but doing this I can see the bridge network has inet set to the gateway ip which means I presumably messed up our network since I duplicated the gateway ip. Why does the bridge take the gateway IP address ? Is this a bug or am I doing something wrong ?


(Sam) #2

not doing anything wrong… what is what the network create does…
sets up the network and gives it a way out (the bridge/gateway)

you cannot give it the existing gateway

by default (and I don’t know if/how to change it) the other side of the gateway goes THRU the host network adapter. but no host outside of the docker host will know about the local network.