After creating a new network with:
docker network create test-net
and running ifconfig
on the host, a new interface name is being listed:
br-f2b630e4e141 Link encap:Ethernet HWaddr 02:42:48:fe:cb:86
inet addr:172.18.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Is there a way to create this network and specify the iface name, for example docker1 or test-net?
In case of docker-compose
, can we also specify iface name inside the docker-compose.yml
file?
Manage a user-defined bridgeUse the docker network create command to create a user-defined bridge network. You can specify the subnet, the IP address range, the gateway, and other options. See the docker network create reference or the output of docker network create --help for details.
There is a --opt
option which can be used like this:
docker network create --opt com.docker.network.bridge.name=br_test test-net
and it seems to work:
$ ifconfig
br_test Link encap:Ethernet HWaddr 02:42:8f:3b:24:32
inet addr:172.18.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
found about --opt
here: https://docs.docker.com/engine/userguide/networking/#the-dockergwbridge-network
inside the docker-compose.yml
:
networks:
test-net:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.100.0.0/16
driver_opts:
com.docker.network.bridge.name: br_test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With