title: Spring boot + docker + rest template connection refused
body: <p>I have two services, spring boot docker and when I try communication with rest template I got java.net.ConnectException: Connection refused (Connection refused)</p>
  
  <p>url is <a href="http://localhost:8081/api/v1/package/250Mbps" rel="nofollow noreferrer">http://localhost:8081/api/v1/package/250Mbps</a></p>
  
  <p>Service 1 docker-compose.yml:</p>
  
  <pre><code>product_catalogue_service:
  image: openjdk:8-jdk-alpine
  ports:
    - "8081:8081"
  volumes:
    - .:/app
  working_dir: /app
  command: ./gradlew bootRun
  restart: on-failure
  </code></pre>
  
  <p>Service 2 docker-compose.yml: </p>
  
  <pre><code>order_service:
  image: openjdk:8-jdk-alpine
  ports:
    - "8083:8083"
  volumes:
    - .:/app
  working_dir: /app
  command: ./gradlew bootRun
  restart: on-failure
  </code></pre>
  
  <p>Rest template URL, and it is working when I run project 2 from the IntelliJ:
  <a href="http://localhost:8081/api/v1/package/250Mbps" rel="nofollow noreferrer">http://localhost:8081/api/v1/package/250Mbps</a></p>
  
  <p>When I run docker ps, name of first service is:
  productcatalogueservice_product_catalogue_service_1</p>
  
  <p>I tried to use that instead of localhost - unknown host exception.</p>
  
  <p>I tried "product_catalogue_service_1" instead, also unknown host exception, 
  and finally I tried "product_catalogue_service" also unknown host exception.</p>
  
  <p>Any idea?</p>