Docker nginx proxy manager with multiple networks / same network multiple mariadb containers

Viewed 21

im currently facing a situation in which i need two different containers both using mariadb (one of them is NPM itself) to run at the same time

im currently running both containers on different networks but as soon as i try to get npm to use both networks i get a bad gateway error.

this is my compose file for npm:


networks:
  static:
    external: true
  firefly:
    external: true
    
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
      # Add any other Stream port you want to expose
      # - '21:21' # FTP
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
      # Uncomment this if IPv6 is not enabled on your host
      # DISABLE_IPV6: 'true'
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    networks:
      static:
        ipv4_address: 172.18.0.3  
      
      
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql
    networks:
      static:
        ipv4_address: 172.18.0.4

and here's the one for the other container:

  firefly:
    external: true


services:
  app:
    image: fireflyiii/core:latest
    hostname: app
    
    restart: always
    volumes:
      - firefly_iii_upload:/var/www/html/storage/upload
    env_file: .env
    ports:
      - '82:8080'
    depends_on:
      - db
    networks:
      firefly:
        ipv4_address: 172.19.0.9
  db:
    image: library/mariadb
    hostname: fireflyiiidb
    networks:
      firefly:
        ipv4_address: 172.19.0.10
    restart: always
    environment:
      - MYSQL_RANDOM_ROOT_PASSWORD=yes
      - MYSQL_USER=firefly
      - MYSQL_PASSWORD=secret_firefly_password
      - MYSQL_DATABASE=firefly
    volumes:
      - monitoring_firefly_iii_db:/var/lib/mysql
     
    

volumes:
 firefly_iii_upload:
   external: true
 monitoring_firefly_iii_db:
   external: true

is this double network thing even the right solution, anything else i can do to make this work?

0 Answers
Related