Hi Long,
Have you found a way to make that happen? You can create a new network with --driver bridge
option and attach it to one of your network interfaces(e.g. eth1
). Here’s an example:
# Delete the IP address from eth1
$ sudo ip addr del 192.168.33.10/24 dev eth1
# Create "shared_nw" with a bridge name "docker1"
$ sudo docker network create \
--driver bridge \
--subnet=192.168.33.0/24 \
--gateway=192.168.33.10 \
--opt "com.docker.network.bridge.name"="docker1" \
shared_nw
# Add docker1 to eth1
$ sudo brctl addif docker1 eth1
After setting the bridge, you can run a container like this.
$ docker run --name container1 --net shared_nw --ip 192.168.33.11 -dt ubuntu
$ ping -c 3 192.168.33.11
I have a more detailed explanation on my github repo. Here’s the link if you’re interested.
https://github.com/kjtanaka/docker-example-shared-nw