1,下载镜像文件
创建docker网络
>docker network create -d bridge docker-net
>docker pull elasticsearch:7.7.0
运行容器
> docker run --network docker-net -d --name es -e "ES_JAVA_OPTS=-Xms1024m -Xmx1024m" -e "discovery.type=single-node" -v G:\develop\docker\elasticsearch\data:/usr/local/elasticsearch/data -v G:\develop\docker\elasticsearch\plugins:/usr/local/elasticsearch/plugins -v G:\develop\docker\elasticsearch\temp:/usr/temp --privileged -p 9200:9200 -p 9300:9300 elasticsearch:7.7.0
进入容器下载ik分词插件
>docker exec -it es bash
>cd plugins/
>mkdir ik
>cd ik
>yum -y install wget
>wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.7.0/elasticsearch-analysis-ik-7.7.0.zip
解压
>unzip elasticsearch-analysis-ik-7.7.0.zip
删除zip
>rm -rf elasticsearch-analysis-ik-7.7.0.zip
退出重启生效
2,设置密码访问
>docker exec -it es /bin/bash
>vi config/elasticsearch.yml
配置内容如下
```linux
cluster.name: "docker-cluster"
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
```
>/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive
输入密码
3,拉取镜像elasticsearch-head
>docker pull mobz/elasticsearch-head:5
运行容器
>docker run --network docker-net -d --name elasticsearch-head -p 9100:9100 mobz/elasticsearch-head:5
访问
>http://127.0.0.1:9100/?auth_user=elastic&auth_password=*****
修改Vendor.js文件第6886、7574行,将"application/x-www-from-urlencodes"修改为"application/json;charset=UTF-8"