0
votes

I am trying to create a local kibana/elastic stack while developing a spring-boot application. I can successfully connect my application to elastic when I launch it as a single container:

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.2.3

My application can connect on 9300, and my web browser can see that it's up on localhost:9200

So... I tried launching the provided stack-docker docker-compose file found here: https://github.com/elastic/stack-docker

Everything seems to setup fine, and I can connect to kibana on localhost:5601, but neither my browser or my application can connect to elastic on 9200 and 9300 respectively.

The only modification from what's checked into github and what I ran is that I added 9300 to the elastic definition.

Any idea what changes I can make to make elastic accessible to my app/browser when running in docker-compose?

1

1 Answers

1
votes

Please add the following docker compose

version: '2.2'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
    container_name: elasticsearch
    environment:
      - cluster.name=elasticsearch
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - esdata1:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
      - 9300:9300
  kibana:
    image: docker.elastic.co/kibana/kibana:6.4.2
    container_name: kibana
    environment:
      - SERVER_NAME=localhost
      - ELASTICSEARCH_URL=http://elasticsearch:9200
      - XPACK.MONITORING.COLLECTION.ENABLED=true
    ports:
      - 5601:5601
volumes:
  esdata1:
    driver: local

After running the kibana url will be available at http://localhost:5601

And elasticsearch url http://localhost:9200/