Installing Elasticsearch with Docker

2022年10月20日 2860点热度 1人点赞 0条评论
内容目录

Create Network and Volume:

docker network create elastic
docker volume create elasticsearch

Create Container:

docker run -itd --name elasticsearch \
  --publish 9200:9200 --net elastic \
  --env discovery.type=single-node \
  --env xpack.security.authc.api_key.enabled=true \
  --volume='elasticsearch:/usr/share/elasticsearch/data' \
  docker.elastic.co/elasticsearch/elasticsearch:8.4.3

This will generate a lot of installation logs:
file

Then enter the container.

docker exec -it elasticsearch bash

Open the /bin directory.
file

Execute the command to reset the password:

./elasticsearch-setup-passwords interactive

file

Run the command to check if the connection is successful:

curl -u elastic http://localhost:9200/

file

Install Kibana:

docker run --name kibana \
  -itd \
  --publish 5601:5601 --net elastic \
  --env ELASTICSEARCH_USERNAME=kibana_system \
  --env ELASTICSEARCH_PASSWORD='your_password' \
  docker.elastic.co/kibana/kibana:8.4.3

If the password is set too simply, you will see:

 Error: [config validation of [elasticsearch].password]: expected value of type [string] but got [number]

In this case, you need to modify each user's password.

 ./elasticsearch-reset-password -u kibana_system

Then copy the generated password, replace it in the command, and recreate Kibana.

Finally, open port 5601 to access Kibana.
file

痴者工良

高级程序员劝退师

文章评论