title: Keycloak authentication problems when using docker and java spring
body: <p>So I have a spring boot application. I also use swagger for testing purposes. 
  I have a keycloak defined inside docker-compose like this:</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>when I try to run my spring boot application I use <code>http://localhost:18080/auth</code> as <code>keycloak_auth_url</code>. When running from my machine everything works.<br>
  When running through docker-compose I change keycloak url to: <code>http://keycloak:18080/auth</code>
  but the url that swaggers uses for redirecting user to keycloak stays the same <code>http://localhost:18080/auth</code>  </p>
  
  <p>Authenticating through swaggers "works". But when I try to call an API endpoint as authenticated user my server returns the following error:  </p>
  
  <pre><code>Error when sending request to retrieve realm keys
  myApp  | 
  myApp  | org.keycloak.adapters.HttpClientAdapterException: IO error
  </code></pre>
  
  <pre><code>Didn't find publicKey for kid: U7a58q_oR3zXWSAwVUIa_7FvhdA7IncCQ2IfKQKDGfI
  myApp  | 2020-01-07 11:58:40.615 ERROR 1 --- [nio-8082-exec-1] o.k.a.BearerTokenRequestAuthenticator    : Failed to verify token
  </code></pre>
  
  <p>Now I am not sure is the problem that my app cannot connect to keycloak to check token. or did checking of token fail?<br>
  thanks for all the help</p>