5

I created a user-defined bridge using the docker command:

docker network create --driver bridge mynetwork

This command resulted in a bridge being created, as shown by netstat -i:

Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
br-000f1  1500        0      0      0 0             0      0      0      0 BMRU

In the same way that I previously trusted the docker0 bridge, I need to add this new bridge to my firewall trust zone:

firewall-cmd --permanent --zone=trusted --add-interface=Docker0

I don't see a way to infer or specify the bridge device name, so I'm not sure how I can add it to my trust zone in an automated way.

I would appreciate any help.

Nathan
  • 113
  • 2
  • 4
  • 2
    Until an answer can be found I am adding IP networks to my trust zone instead of link devices. `firewall-cmd --permanent --zone=trusted --add-source=172.16.0.0/12` – Nathan Nov 29 '17 at 08:02

2 Answers2

5

Elaborating on Marek's Answer of setting the bridge name at creation time.

docker network create --driver bridge -o \
  "com.docker.network.bridge.name"="mynetwork_name" mynetwork

or if using a docker-compose file the following in the networks section

version: '3'
  .
  .
  .
networks:
  mynetwork:
    driver_opts:
      com.docker.network.bridge.name: mynetwork_name
Ian Williams
  • 51
  • 1
  • 2
  • 1
    Is there a way to make the firewalld rule persistent with this approach, so it survives a reboot? The --permanent switch does not work, because the interface does not exist until you create it with docker-compose up (or on the command line). – Kevin Keane Mar 21 '20 at 04:54
0

Docker has option to set a bridge name on creation time

https://docs.docker.com/engine/reference/commandline/network_create/#bridge-driver-options

Marek
  • 11
  • 2
    Please copy the important parts of the web site you linked into the answer. Links change or go dead frequently, and it would be best if this answer could continue to serve the community long after the link has died. – Todd Wilcox May 04 '18 at 14:22