Set bridge name in docker-compose.yml

  bridge, docker, docker-compose

I’m running a dockerized GitLab instance with "userns-remap" enabled and I’d like to use a shared PostgreSQL on the host. The bridge created when I docker-compose up, however, gets a new random name "br-xxxxxxxxxxxx" on every run.

This wouldn’t usually be a problem, but the Vuurmuur firewall on the host blocks all traffic from the container to the host by default and I need the bridge name in order to set an allowing rule on Vuurmuur.

I found a number of related topics e.g. com.docker.network.bridge.name, but I’m having trouble puzzling it all together. So far, I’ve tried to find a way to make sure every time the container is upped, the bridge gets the same name and same IP/mask assigned. Is this even possible in docker-compose.yml or is this approach utterly wrong?

Here’s the unspectactular docker-compose.yml so far:

version: '3.8'
services:
  web:
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    hostname: 'gitlab.example.com'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.example.com'
        gitlab_rails['db_adapter'] = 'postgresql'
        gitlab_rails['db_host'] = '172.18.0.1'
        (...)
    ports:
      - '8080:80'
    volumes:
      (...)

Thanks for any hints!

Source: Docker Questions

LEAVE A COMMENT