2020-04-28 17:29:52 +02:00
---
title: "Docker compose predictable bridge"
date: 2018-09-25
2021-03-11 19:47:26 +01:00
description: How to use a predefined bridge with docker compose
tags:
- docker
2020-04-28 17:29:52 +02:00
---
2021-03-11 19:47:26 +01:00
## The problem
2020-04-28 17:29:52 +02:00
By default, docker-compose will create a network with a randomly named bridge. If you are like me using a strict firewall on all your machines, this just cannot work.
2021-03-11 19:47:26 +01:00
## The fix
For example if your bridge is named docbr1, you need to put your services in `network_mode: “bridge”` and add a custom `network` entry like :
2020-04-28 17:29:52 +02:00
{{< highlight yaml > }}
version: '3.0'
services:
sshportal:
image: moul/sshportal
environment:
- SSHPORTAL_DEFAULT_ADMIN_INVITE_TOKEN=integration
command: server --debug
depends_on:
- testserver
ports:
- 2222
network_mode: "bridge"
networks:
default:
external:
2021-03-11 19:47:26 +01:00
name: docbr1
2020-04-28 17:29:52 +02:00
{{< / highlight > }}