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!
That option is part of the networks driver_opts configuration
$ cat docker-compose.yaml
---
services:
sleep:
image: ubuntu
command: [sh, -c, "sleep infity"]
networks:
demo:
networks:
demo:
driver_opts:
com.docker.network.bridge.name: br-demo
$ docker-compose up -d
Creating network "tmp_demo" with the default driver
Creating tmp_sleep_1 ... done
$ brctl show
bridge name bridge id STP enabled interfaces
br-demo 8000.02423d13fd2a no
docker0 8000.02428a615bfa no
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