I recently wanted to debug something on my linux server and listed all bridges. The output was disappointing. All bridges were named with random strings like this:

br-2b6b3cc75104
br-41da10d6d383

I create all my bridges with ansible and it seems that the ansible docker_network module is not very good at naming things in a human readable way. But there is a way you can influence the system bridge names when using docker through ansible.

The following applies to Linux systems.

Where do ansible managed docker bridge names come from?

When you create a new docker network with ansible, docker creates a new system bridge for you. The name consists of a prefix br- and a hex string with the first 12 characters of the id of the docker network that uses the bridge.

How to name ansible managed docker bridges

To assign a name to the system bridge when creating a docker network with ansible you can pass the driver option com.docker.network.bridge.name. The bridge name has a 15 character limit. Consider the following example of an ansible task that creates a network and sets the bridge name:

- name: Ensure plausible network
docker_network:
name: plausible
appends: yes
driver_options:
com.docker.network.bridge.name: docker-plausibl

How to find out which bridge belongs to which docker network

When you already have several bridges with random names and you need to find out which docker network they belong to, you can inspect the docker network and look for the network id. The bridge name will use the first 12 characters of the docker network id as an identifier:

benjamin@tnglab:~$ docker network inspect wekan
[
{
"Name": "wekan",
"Id": "56055d95f648f6aed2002a78eee3530ff2ef92be7410f50bac87f5f75dbbcf62",
...

In this example the bridge name would be br-56055d95f648.

How does it look in practice?

Setting the bridge names, I went from this:

benjamin@tnglab:~$ brctl show
bridge name bridge id STP enabled interfaces
br-896b3cc75144 8000.0242928bd08e no veth1643759
veth46fee36
veth7fb5ff4
br-2b6b3cc75104 8000.02420819e6ce no veth063b6c1
veth08d3401
veth1cd4190
veth84f2ab0
veth9de5feb
veth9f85418
vethe055863
br-41da10d6d383 8000.02427fa5b26d no veth14d2523
vethad48648
vethdfafa4d
vethfd41177
br-8b204b99335b 8000.0242ae393b8e no veth2dc900f
veth552856f
veth563643b
vetha73d54a
br-e04d746feb69 8000.02420fb1c153 no veth25c1e98
veth88d1e12
vethdc13c5e
br-a7508dea30bc 8000.0242b3bf66ba no veth3d4b503
veth52b2011
vethcd0ffb1
docker0 8000.024253a238a5 no veth1fa3e89
vetha16c945

To this:

benjamin@tnglab:~$ brctl show
bridge name bridge id STP enabled interfaces
docker-atlassia 8000.0242fc4f8c5a no veth1d300c7
veth3b8730f
vethc7e61fa
vethd1b6d61
docker-mail 8000.0242bfd1009e no veth583dc56
veth9e2b1a7
vethfb00e5b
docker-plausibl 8000.0242fb8c86ec no veth68cc751
veth7d3879b
vethddaac1e
docker-seafile 8000.02429be7e8d6 no veth1f7a2da
veth4ddc220
veth7c9163a
veth7e826c6
docker-traefik 8000.0242ab033b99 no veth40176ba
veth544d840
veth5d26b1e
veth8021706
vetha2830f3
vethe0aadff
vethff3bcfe
docker-wekan 8000.0242b3bf66ba no veth3d4b503
veth52b2011
vethcd0ffb1
docker0 8000.024253a238a5 no veth1fa3e89
vetha16c945

Much more helpful. And I even forgot what I wanted to debug in the first place. Problem solved…