Run the containers in default bridge network with docker-compose.yml

Image result for docker-compose

By default, docker-compose creates a new network for each docker-compose.yml file. This might be a problem if you are running traefik container as reverse proxy in different network(usually default)

If you want to run the services in default docker bridge network simply add network_mode: bridge to the each service definition.

Here is an example docker-compose.yml file

# cat docker-compose.yml 
version: '3'
services:
web:
image: maki/modx
network_mode: bridge
links:
- 'modxdb:mysql'
labels:
traefik.enable: "true"
traefik.protocol: "http"
traefik.port: 80
traefik.frontend.rule: "Host:www.mydomain.com"
environment:
MODX_VERSION: 2.7.1
MODX_DB_HOST: 'mysql:3306'
MODX_DB_PASSWORD: modx
MODX_DB_USER: modx
MODX_DB_NAME: modx
volumes:
- './html:/var/www/html'
modxdb:
image: 'mysql:5.7'
network_mode: bridge
environment:
MYSQL_ROOT_PASSWORD: modx
MYSQL_DATABASE: modx
MYSQL_USER: modx
MYSQL_PASSWORD: modx
command: mysqld --sql-mode=NO_ENGINE_SUBSTITUTION
volumes:
- '/dockerdata/modx.mydomain/var_lib_mysql:/var/lib/mysql'
phpmyadmin:
image: phpmyadmin/phpmyadmin
network_mode: bridge
links:
- 'modxdb:db'
labels:
traefik.enable: "true"
traefik.protocol: "http"
traefik.port: 80
traefik.frontend.rule: "Host:phpmyadmin.mydomain.com"

Ismail YENIGUL

Devops Engineer at Feedstock Inc.