title: Docker nginx proxy manager with multiple networks / same network multiple mariadb containers
body: <p>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</p>
  <p>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.</p>
  <p>this is my compose file for npm:</p>
  <pre><code>
  networks:
    static:
      external: true
    firefly:
      external: true
      
  services:
    app:
      image: 'jc21/nginx-proxy-manager:latest'
      restart: unless-stopped
      ports:
        # These ports are in format &lt;host-port&gt;:&lt;container-port&gt;
        - '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: &quot;db&quot;
        DB_MYSQL_PORT: 3306
        DB_MYSQL_USER: &quot;npm&quot;
        DB_MYSQL_PASSWORD: &quot;npm&quot;
        DB_MYSQL_NAME: &quot;npm&quot;
        # 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
  
  </code></pre>
  <p>and here's the one for the other container:</p>
  <pre><code>  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
  </code></pre>
  <p>is this double network thing even the right solution, anything else i can do to make this work?</p>