docker-compose.yml for elasticsearch and kibana
To add the hard dependency on elasticsearch for kibana, you need the depends_on variable to be set as shown below. Also, to add to @Phil McMillan's answer, you can set the elasticsearch_url variable in kibana, without static addressing using Docker's inbuilt DNS mechanism.
version: '2.1'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.4.3
container_name: elasticsearch
networks:
docker-elk:
kibana:
image: docker.elastic.co/kibana/kibana:5.4.3
container_name: kibana
environment:
- "ELASTICSEARCH_URL=http://elasticsearch:9200"
networks:
- docker-elk
depends_on:
- elasticsearch
networks:
docker-elk:
driver: bridge
Note the environment variable ELASTICSEARCH_URL=http://elasticsearch:9200 just uses has the container name (elasticsearch) which the Docker DNS server is able to resolve.
This works for me
docker-compose.yml
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
environment:
- discovery.type=single-node
ports:
- 9200:9200
kibana:
image: docker.elastic.co/kibana/kibana:7.6.2
ports:
- 5601:5601
You need to include the links
.
version: "2.0"
services:
elasticsearch:
image: elasticsearch:latest
ports:
- "9200:9200"
- "9300:9300"
networks:
- docker_elk
kibana:
image: kibana:latest
ports:
- "5601:5601"
links:
- elasticsearch
networks:
- docker_elk
networks:
docker_elk:
driver: bridge
UPDATED
When using the image elasticsearch:latest
, it's Elasticsearch 5.0
and requires us to increase our Docker host virtual memory.
Before running the docker-compose
, please make sure to run this command on your Docker host.
Linux:
su root
sysctl -w vm.max_map_count=262144
Windows (boot2docker)
docker-machine ssh default
sudo sysctl -w vm.max_map_count=262144
If you don't want to change your Docker host, just use the Elasticsearch 2.x
image at elasticsearch:2