安装elasticsearch
1、执行命令:docker pull elasticsearch:8.11.1
2、执行命令:docker run --name elastic -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:8.11.1
3、执行命令:docker exec -it elastic /bin/bash
4、执行命令:cd bin
5、执行命令:elasticsearch-setup-passwords interactive
6、设置所有用户的用户名
6、执行命令:docker restart elastic
7、进入https://localhost:9200查看是否可以访问
安装elasticsearch-head
1、docker pull mobz/elasticsearch-head:5
2、docker run --name elastic-head -p 9100:9100 -d mobz/elasticsearch-head:5
3、复制配置文件到本地修改:docker cp elasticsearch:/usr/share/elasticsearch/config/elasticsearch.yml d:/
4、在文件末尾添加
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
5、上传文件:docker cp d:\elasticsearch.yml elasticsearch:/usr/share/elasticsearch/config/
6、重启:docker restart elasticsearch
7、连接:http://localhost:9100/?auth_user=elastic\&auth_password=xxxxx