Docker Community Forums

Share and learn in the Docker community.

Docker network bridge on same subnet as host, own IP

docker

#1

I would like to set a specific IP for one of my containers running on Synology DSM 6.2.1 with Docker version 17.05.0-ce, build 9f07f0e-synology. uname -r = 3.10.105.

What is the easiest way to get an exclusive IP for a container (same subnet as host)?

I tried:

docker network create \
--driver bridge \
--ip-range=192.168.1.0/24 \
--subnet=192.168.1.0/24 \
--gateway=192.168.1.1 \
my_bridge

but it didn’t end well, my synology’s dns stopped working and I couldn’t access it from WAN.

Can you create a network on the same subnet as the host?


#2

no, you can’t. You created an ip-range collision, which results in messy ip-tables rules. Local LAN and bridged networks are not the “the same” network, regardless wheather you assign the same ip-range or not.

What you try to do, can be solved with macvlan ip. See this post in syno community: https://community.synology.com/forum/15/post/120118

Though, honestly: I run dozens of Docker containers and I never ever needed a macvlan network.

Usualy, people how try to enforce their VM knowledge to docker containers, end up “requiring” such a solution.


#3

Thanks!

I’ve actually asked if I should use mavlan or something else on reddit.
I was told to use a bridge…

I want to manage the bandwith from that contaiener on my router.


#4

I can’t see how bridged or host network would allow to distinguish a single container from all others.
I am aware that CPU, RAM and Storage (io/bw) limitations can be enforced. As far as I know, network io/bw restrictions are not implemented in Docker.

In this scenario macvlan seems like the valid approach to try.