title: Docker-compose external_links not able to connect
body: <p>I have a couple of app containers that I want to connect to the mongodb container. I tried with external_links but I can not connect to the mongodb.</p>
  
  <p>I get</p>
  
  <blockquote>
    <p>MongoError: failed to connect to server [mongodb:27017] on first
    connect</p>
  </blockquote>
  
  <p>Do I have to add the containers into the same network to get external_links working?</p>
  
  <p><strong>MongoDB:</strong></p>
  
  <pre><code>version: '2'
  services:
    mongodb:
      image: mongo:3.4
      restart: always
      ports:
        - "27017:27017"
      volumes:
        - data:/data/db
  volumes:
    data:
  </code></pre>
  
  <p><strong>App:</strong></p>
  
  <pre><code>version: '2'
  services:
    app-dev:
      restart: Always
      build: repository/
      ports:
        - "3000:80"
      env_file:
        - ./environment.env
      external_links:
        - mongodb_mongodb_1:mongodb
  </code></pre>
  
  <p><strong>Networks:</strong></p>
  
  <pre><code># sudo docker network ls
  NETWORK ID          NAME                      DRIVER              SCOPE
  29f8bae3e136        bridge                    bridge              local
  67d5519cb2e6        dev_default               bridge              local
  9e7097c844cf        host                      host                local
  481ee4301f7c        mongodb_default           bridge              local
  4275508449f6        none                      null                local
  873a46298cd9        prod_default              bridge              local
  </code></pre>