Linked docker containers can't communicate with each other
<p>I am using docker-compose to run my application stack.</p>

<p>The application stack is:</p>

<ol>
<li>Mongo</li>
<li>Rest Service (referred as rest-service hereafter)</li>
<li>UI Service (referred as ui-service hereafter)</li>
</ol>

<p>Below is the snippet of my docker-compose:</p>

<pre><code>services:
  mongodb:
    image: mongo:3
    container_name: mongodb
    ports:
      - "17027:27017"

  rest-service:
    build: ./rest-service/
    container_name: rest
    ports:
      - "15000:5000"
    command: "/opt/app/conf/config.yml"
    links:
      - mongodb:mongo

  ui-service:
    build: ./ui-service/
    container_name: ui
    ports:
     - "18080:8080"
    links:
      - rest-service:rest
    environment:
      NODE_ENV: development
</code></pre>

<p>The problem I am facing over here is that my rest-service can talk to mongo container (I mean on port(27017 on docker container)), since mongo is linked to restService. But ui-service cant talk to rest-service(I mean on port(5000 on docker container)).</p>

<p>If I try to make ui-service talk to rest-service on host port (I mean port 15000 which listens on port 5000 of docker container), it works.
Hence, I am not able to understand why this happens. </p>

<p>Any help would be highly appreciated.</p>