I am creating a user-defined docker network using the ‘docker network create’ command.
docker network create -d bridge MyTestBridge
527e157424798de64d487e8f92238574dc6c758723e12b56af22fa03c33ad5bb
docker network ls NETWORK ID NAME DRIVER SCOPE
527e15742479 MyTestBridge bridge local
ip -c a
13: br-527e15742479: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:6a:f3:dc:ea brd ff:ff:ff:ff:ff:ff
inet 172.18.0.1/16 brd 172.18.255.255 scope global br-527e15742479
The bridge network interface has a different random name, br-527e15742479.
How do I make the docker network command to create a bridge interface with the name provided in the create command, MyTestBridge
docker network create -d bridge MyTestBridge
Checked docker documentation,
https://docs.docker.com/reference/cli/docker/network/create/
user3777764 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
The answer is in the document to which you linked, in the section “Bridge driver options”:
Option | Equivalent | Description
------------------------------+------------+-------------------------------
com.docker.network.bridge.name - Bridge name to be used when
creating the Linux bridge
So if you run this command:
docker network create -d bridge -o com.docker.network.bridge.name=mybridge mynetwork
You end up with a bridge device named mybridge
:
$ ip addr show mybridge
488: mybridge: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:ac:85:b1:d9 brd ff:ff:ff:ff:ff:ff
inet 172.28.0.1/16 brd 172.28.255.255 scope global mybridge
valid_lft forever preferred_lft forever
1