title: How to get two Docker containers talking to each other?
body: <p>I've got two Docker containers running. One is MongoDB and one is a container running a simple rest API that should be able to query the MongoDB container.</p>
  
  <p>Port mappings</p>
  
  <ul>
  <li>0.0.0.0:28001->27017/tcp (mongodb)</li>
  <li>0.0.0.0:3000->3000/tcp (restapi)</li>
  </ul>
  
  <p>Commands used for the MongoDB image</p>
  
  <pre><code>docker run -p 28001:27017 -v /home/ubuntu/docker/mongodb/mongod.conf:/etc/mongod.conf --name mongodb_container -d mongodb_image
  </code></pre>
  
  <p>I override mongo.conf to add 0.0.0.0 to bind IP</p>
  
  <pre><code>net:
    port: 27017
    bindIp: [127.0.0.1,0.0.0.0]
  </code></pre>
  
  <p>Run command used for the API:</p>
  
  <pre><code>docker container run -it -v /home/ubuntu/docker/node_modules:/usr/lib/node_modules -p 3000:3000 --name rest_container rest_image /bin/bash
  </code></pre>
  
  <p>I'm able to query the rest api, but it hangs and times out (never returns result). The rest config file looks something like this:</p>
  
  <pre><code>{ "db": {
    'port': 28001,
    'host': "192.168.123.191"
    },
    'server': {
      'port': 3000,
          'timeout': 120,
      'address': "0.0.0.0"
    },
    'flavor': "regular",
    'debug': true
  };
  </code></pre>
  
  <p>Internal IP of the rest api container:</p>
  
  <p>172.17.0.4</p>
  
  <p>Internal IP of the mongodb container:</p>
  
  <p>172.17.0.2</p>
  
  <p>I know the API works because I'm able to do queries without running the programs on docker. Ports 27017 and 3000 are both exposed in the Dockerfile. In the mongodb container I can also see that the number of connections increases every time I do a query. </p>