title: How to connect to localhost and external database from docker container
body: <p>I have two docker containers, nginx and php, from which I want to access mysql server running on host machine and sql server on remote machine. </p>
  
  <p>Have tried change the network type from "bridge" to "host" but it returns errors.</p>
  
  <pre><code>version: '2'
  
  services:
      web:
          image: nginx:latest
          ports:
              - "8080:80"
          volumes:
              - /var/www/:/code
              - ./site.conf:/etc/nginx/conf.d/default.conf
          networks:
              - mynetwork
      php:
          image: php:fpm
          volumes:
              - /var/www/:/code
          networks:
             - mynetwork
  networks:
      mynetwork:
         driver: bridge
  </code></pre>
  
  <p>I'm expecting php code running in my containers can connect to those two databases.</p>
  
  <p>Note: I don't using <code>docker run</code> to run container, instead I'm using <code>docker-compose up -d</code> so I just want to edit the <code>docker-compose.yml</code> file.</p>