docker network create elastic
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.1.2
docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.1.2
# copy http security crt
docker cp es-node01:/usr/share/elasticsearch/config/certs/http_ca.crt .
# get response from elasticsearch
curl -X GET "https://localhost:9200" -u "elastic:{pw}" --cacert http_ca.crt
# http_ca.crt를 /etc/ssl/cert.pem에 등록하여 사용
# attach into docker container
docker exec -it es-node01 /bin/bash
vi /usr/share/elasticsearch/config/elasticsearch.yml
# disable xpack security - modify line as below
xpack.security.enabled: false
docker pull docker.elastic.co/kibana/kibana:8.1.2
docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.1.2
# index 조회
curl -X GET "http://localhost:9200/_cat/indices?v"
index=user, doc_id=1에 {"username": "kin"} document를 추가한다.
curl -X PUT "http://localhost:9200/user/_doc/1" -H "Content-Type: application/json" -d '{"username": "kin"}'
curl -X GET "http://localhost:9200/user/_doc/1"
pretty option을 주면 가독성 좋게 볼 수 있다.
curl -X GET "http://localhost:9200/user/_doc/1?pretty"
curl -X GET "http://localhost:9200/user/_mapping?pretty"