I need 2 networks in my compose file, 1 for main service to connect to mysql and another for main service to connect to proxy.
Proxy is common to many other compose files so I don’t want mysql on that network.
In my case I need to connect to mysql using monica_backend and to the proxy using proxy-proxy-tier.
If I comment out the proxy network in the mysql service monica can’t connect to mysql.
So here’s the file:
"version: "3.4" services: app: image: monica depends_on: - db environment: - APP_KEY=xxx - DB_HOST=db - VIRTUAL_HOST=xxx.xxx.com - LETSENCRYPT_HOST=xxx.xxx.com - LETSENCRYPT_EMAIL=xxxxxx volumes: - ./data:/var/www/html/storage restart: always networks: monica_backend: proxy_proxy-tier: db: image: mysql:5.7 environment: - MYSQL_RANDOM_ROOT_PASSWORD=true - MYSQL_DATABASE=xxx - MYSQL_USER=xxx - MYSQL_PASSWORD=xxx volumes: - ./mysql:/var/lib/mysql restart: always networks: monica_backend: commented out proxy_proxy-tier: (not sure how to make # come out in markdown) networks: monica_backend: driver: bridge proxy_proxy-tier: external: true"
When I do a docker-compose up and look at the scrolling logs it says “can’t connect to mysql:3306”. If I remove the comment before the proxy network in the db service monica can connect.
Help much appreciated.