title: Spring boot unable to connect to elasticsearch docker
body: <p>My Elasticsearch docker-compose file is as such</p>
  
  <pre><code>version: '3'
  
  services:
    elasticsearch:
      image: docker.elastic.co/elasticsearch/elasticsearch:6.8.6
      container_name: elasticsearch
      environment:
        - cluster.name=cluster
        - bootstrap.memory_lock=true
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      ulimits:
        memlock:
          soft: -1
          hard: -1
      volumes:
        - ./config/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/elasticsearch.yml
        - esdata6:/usr/share/elasticsearch/data    
      ports:
        - "9200:9200"
    kibana:
      image: docker.elastic.co/kibana/kibana:6.8.6
      container_name: kibana
      volumes:
        - ./config/kibana/kibana.yml:/usr/share/kibana/kibana.yml
      restart: on-failure
      ports:
        - "5601:5601"
  
  volumes:
    esdata6:
  </code></pre>
  
  <p>I have a spring boot application and the application.properties is </p>
  
  <pre><code>spring.data.elasticsearch.repositories.enabled=true
  spring.data.elasticsearch.cluster-nodes=localhost:9200
  spring.data.elasticsearch.cluster-name=cluster
  </code></pre>
  
  <p>However, I am getting the error </p>
  
  <pre><code>2020-04-18 13:49:45.775  INFO 7576 --- [           main] o.s.d.e.c.TransportClientFactoryBean     : Adding transport node : 127.0.0.1:9200
  2020-04-18 13:50:16.961 ERROR 7576 --- [           main] .d.e.r.s.AbstractElasticsearchRepository : failed to load elasticsearch nodes : org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{Lzoi5ddvSJizvu4g3Y3E6Q}{localhost}{127.0.0.1:9200}]
  </code></pre>
  
  <p>Question: 
  1) How can i connect to the elasticsearch with spring boot externally?
  2) If I docker-compose up the elastic and the springboot application together, they would be on the same network. What change should I ammend to spring.data.elasticsearch.cluster-nodes in order to connect to the elastic search? </p>
  
  <p>I am using spring-boot-starter-data-elasticsearch in the spring boot app. </p>