- vi docker-compose.yml
To get Elasticsearch cluster and kibana up and running in Docker, you can use Docker Compose.
If you don’t want to expose port 9200 and instead use a reverse proxy, replace 9200:9200 with 127.0.0.1:9200:9200 in the docker-compose.yml file. Elasticsearch will then only be accessible from the host machine itself(www.elastic.co/guide/en/elasticsearch/reference/current/docker.html).
version: '3.5'
services:
es:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
container_name: es
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
ports:
- 9200:9200
networks:
- ekl
kibana:
image: docker.elastic.co/kibana/kibana:7.10.2
container_name: kibana
ports:
- 5601:5601
environment:
ELASTICSEARCH_URL: http://es:9200
ELASTICSEARCH_HOSTS: http://es:9200
depends_on:
- es
networks:
- ekl
networks:
ekl:
driver: bridge
- docker-compose up -d
-d : Detached, opposite to -i -t in other words, it estabilished running the application on the foreground, unlike interactive mode -i -t. It executes the container without input and output. It doesnt receive user's input.
- docker-compose logs --tail 100 -f
Displays log output from services.
Attaching to kibana, es
es | {"type": "server", "timestamp": "2021-04-12T09:50:14,977Z", "level": "INFO", "component": "o.e.p.PluginsService", "cluster.name": "docker-cluster", "node.name": "cabe98f0ad02", "message": "loaded module [x-pack-data-streams]" }
...
--tail : number of lines to show from the end of the logs for each container.
-f : follow, follow log output
- curl -X GET "localhost:9200/_cat/nodes?v=true&pretty"
Submit a _cat/nodes request to see that the nodes are up and running.
_cat/nodes : Returns information about a cluster's nodes.
curl -X GET "localhost:9200/_cat/nodes?v=true&pretty"
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.19.0.2 48 95 1 0.04 0.06 0.05 cdhilmrstw * cabe98f0ad02
- docker-compose down
To stop the cluster. The data in the Docker volumes is preserved and loaded when you restart the cluster with docker-compose up.