Skip to content

Instantly share code, notes, and snippets.

@mourjo
Last active April 13, 2024 21:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mourjo/be9106be907152595dd3582c6ade2987 to your computer and use it in GitHub Desktop.
Save mourjo/be9106be907152595dd3582c6ade2987 to your computer and use it in GitHub Desktop.
Docker compose for a minimal Kibana + Elasticsearch locally
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms128m -Xmx512m"
- xpack.security.enabled=false
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- data01:/usr/share/elasticsearch/data
ports:
- 9201:9200
networks:
- elastic
kib01:
image: docker.elastic.co/kibana/kibana:7.15.1
container_name: kib01
ports:
- 5602:5601
environment:
ELASTICSEARCH_URL: http://es01:9200
ELASTICSEARCH_HOSTS: '["http://es01:9200"]'
networks:
- elastic
volumes:
data01:
driver: local
networks:
elastic:
driver: bridge
@mourjo
Copy link
Author

mourjo commented Nov 8, 2021

Try it out on the host machine with

Create an index with one field in the mapping

curl -XPUT "http://localhost:9201/test" -H 'Content-Type: application/json' -d'
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
    "properties": {
      "body": { "type": "text" }
    }
  }
}'

Index (insert) one document

curl -XPOST "http://localhost:9201/test/_doc" -H 'Content-Type: application/json' -d'
{
  "body": "i am a value"
}'

Search for documents

curl -XPOST "http://localhost:9201/test/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "match": {
      "body": "value"
    }
  }
}'

@mourjo
Copy link
Author

mourjo commented Nov 8, 2021

Alternatively use the dev tools console in Kibana http://localhost:5602/app/dev_tools#/console

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment