title: Docker - SpringConfig - Connection refused to ConfigServer
body: <p>I'm trying to deploy a ConfigServrService and a Client with a remote repository using DockerCompose.</p>
  
  <p>The docker-compose.yml is like:</p>
  
  <pre><code>version: '2'
  
  services:
  
    rabbitmq:
      image: rabbitmq
      ports:
        - "5672:5672"
  
    config-server:
      image: config-server
      environment:
        - "SPRING_PROFILES_ACTIVE=desa"
      ports:
        - "8888:8888"
      links:
        - rabbitmq
      depends_on:
        - rabbitmq
  
    user-service-config:
      image: user-service-config
      environment:
        - "SPRING_PROFILES_ACTIVE=desa"
      ports:
        - "8090:8090"
      links:
        - config-server
        - rabbitmq
      depends_on:
        - rabbitmq
        - config-server
  </code></pre>
  
  <p>At the moment that they are deploying, the client console shows:</p>
  
  <blockquote>
    <p>c.c.c.ConfigServicePropertySourceLocator : Fetching config from server
    at: <a href="http://localhost:8888" rel="nofollow noreferrer">http://localhost:8888</a></p>
  </blockquote>
  
  <p>(Instead of <a href="http://config-server:8888" rel="nofollow noreferrer">http://config-server:8888</a>)</p>
  
  <p>And after that, the console shows: </p>
  
  <blockquote>
    <p>Could not locate PropertySource: I/O error on GET request for
    "<a href="http://localhost:8888/user-server-config/desa" rel="nofollow noreferrer">http://localhost:8888/user-server-config/desa</a>": Connection refused;
    nested exception is java.net.ConnectException: Connection refused</p>
  </blockquote>
  
  <p>The service is trying to connet to <a href="http://localhost:8888/user-server-config/desa" rel="nofollow noreferrer">http://localhost:8888/user-server-config/desa</a> instead of <a href="http://config-server:8888" rel="nofollow noreferrer">http://config-server:8888</a>.</p>
  
  <p>The application.yml file of the client is:</p>
  
  <pre><code>server:
    port: 8090
  spring:
    rabbitmq:
      host: 172.17.0.1
      port: 5672
      username: guest
      password: guest
  
    application:
      name: user-server-config
    cloud:
      enabled: true
      config:
        uri: http://config-server:8888
        failFast: true
        retry:
          maxAttempts: 20
  
  management:
    security:
      enabled: false
  </code></pre>
  
  <p>I do not know why the uri contains <strong><a href="http://localhost:8888" rel="nofollow noreferrer">http://localhost:8888</a></strong> with <strong>/user-server-config/desa</strong> at the end. Instead of <strong><a href="http://server-config:8888" rel="nofollow noreferrer">http://server-config:8888</a></strong> as is indicated in the application.yml</p>