title: communication between docker containers (keycloak and spring)
body: <p>So I have created a java spring boot application which uses Keycloak for authenticating its users. 
  When I run keycloak from docker-compose I can sucesfully authenticate when running my application as a standalone jar file or when debugging. But when I put my spring boot application as a docker containers inside docker-compose. I cannot authenticate users anymore.  </p>
  
  <p>my error log from spring boot docker container:</p>
  
  <pre><code>springBootApp  | 2019-12-19 13:16:41.498 ERROR 1 --- [nio-8081-exec-2] o.k.a.rotation.JWKPublicKeyLocator       : Error when sending request to retrieve realm keys
  springBootApp  | 
  springBootApp  | org.keycloak.adapters.HttpClientAdapterException: IO error
  </code></pre>
  
  <p>I though that the problem is with network. but all containers are running in the same virtual network. They are also also in same docker-compose file.</p>
  
  <p>this is my keycloak part:</p>
  
  <pre><code>  keycloak:
      image: jboss/keycloak
      ports:
        - 18080:8080
      volumes:
          - ../keycloak:/opt/jboss/keycloak/imports
      command: 
          - "-b 0.0.0.0 -Dkeycloak.import=/opt/jboss/keycloak/imports/realm-export.json"
      environment:
                - KEYCLOAK_USER=admin
                - KEYCLOAK_PASSWORD=admin
  </code></pre>
  
  <p>my spring boot app</p>
  
  <pre><code>  mySpringBootApp:
      image: mySpringBootApp:master-1
      environment:
        - SPRING_PROFILES_ACTIVE=developmentTest
      depends_on: 
        - jaeger
        - keycloak
        - db
      ports:
        - "8081:8081"
  </code></pre>
  
  <p>When I try to use
  <code>curl localhost:18080</code> from my host. I get the response.
  when I try to use curl from springBootApp docker I get connection refused. So I assume that even though they are in the same network they don't see each other.</p>