title: Docker HTTP-requests between containers
body: <p>I'm at the first stage in learning how to use Docker so I'm trying basic things. I've created two Node Express services that need to exchange data via HTTP-requests.</p>
  
  <p><strong>My <code>docker-compose.yml</code> file</strong></p>
  
  <pre><code>networks:
    isolation-network:
      driver: bridge
  
  services:
    service1-nodejs:
      build:
      context: ./service1/
      dockerfile: .docker/node.dockerfile
      ports:
        - "10000:9000" 
        - "10001:5858" 
      env_file: ./service1/.docker/env/app.${APP_ENV}.env
      networks:
        - isolation-network
  
    service2-nodejs:
      build:
      context: ./service2/
      dockerfile: .docker/node.dockerfile
      ports:
        - "10010:9000" 
        - "10011:5858" 
      env_file: ./service2/.docker/env/app.${APP_ENV}.env
      networks:
        - isolation-network
  </code></pre>
  
  <p><code>service1</code> uses the <a href="https://github.com/request/request" rel="noreferrer">request module</a> to make a POST-request to <code>service 2</code>.</p>
  
  <pre><code>request({ url: "http://service2:10010/api/",
                  method: "POST",
                  headers: { "Content-Type": "application/json" },
                  json: true,
                  body: { ... },
                  time: true
              }, function (err, res, body) {
                  if (!err &amp;&amp; res.statusCode == 200) {
                      // success
                  }
  
                  // failed
              });
  </code></pre>
  
  <p>The result of this call is:</p>
  
  <blockquote>
    <p>{ Error: connect ECONNREFUSED 172.18.0.3:10010}</p>
  </blockquote>
  
  <p>Using postman I can test <code>service2</code> at <code>http://localhost:10010/api/</code> and I can confirm they actually can be reached and work as expected.</p>
  
  <p>I'm missing something but can't figure it out. What is going wrong here?</p>