#下载镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.12.0
#创建容器用户数据拷贝
docker run -d --name elastic -p 9200:9200 --privileged -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" docker.elastic.co/elasticsearch/elasticsearch:8.12.0
#copy文件
mkdir -p /docker/volume/es
docker cp -a elastic:/usr/share/elasticsearch/plugins/ /docker/volume/es
docker cp -a elastic:/usr/share/elasticsearch/config/ /docker/volume/es
docker cp -a elastic:/usr/share/elasticsearch/data/ /docker/volume/es
#暂停容器 删除
docker stop elastic
docker rm elastic
docker run -d --name es -p 9200:9200 -p 9300:9300 --privileged -v /docker/volume/es/data:/usr/share/elasticsearch/data -v /docker/volume/es/plugins:/usr/share/elasticsearch/plugins -v /docker/volume/es/config:/usr/share/elasticsearch/config -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms512m -Xmx512m" docker.elastic.co/elasticsearch/elasticsearch:8.12.0
3:重置密码
docker exec -it es bash
bin/elasticsearch-reset-password -u elastic -i 123456
4:安装kibana #创建容器cope配置
docker run --name kibana --net=host -p 5601:5601 -d kibana:8.12.0
docker cp kibana:/usr/share/kibana/config/ /docker/volume/kibana/config/
docker stop kibana
docker rm kibana
创建容器
docker run --name kibana -p 5601:5601 -v /docker/volume/kibana/config:/usr/share/kibana/config -d kibana:8.12.0
访问 web http:127.0.0.1:5601 es生成sing
docker exec -it es /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
es生成密码
docker exec -it es /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic -i
获取kibana验证码
docker exec -it es /usr/share/kibana/bin/kibana-verification-code
#设置中文修改配置文件/docker/volume/kibana/config/kibana.yml添加
i18n.locale: "zh-CN"
5:安装ik分词器
地址 https://github.com/infinilabs/analysis-ik/releases
进入目录 /docker/volume/es/plugins 创建文件中 权限设置
mkdir ik
chmod -R777 ik
#下载分词器 wget https://github.com/infinilabs/analysis-ik/releases/download/v8.12.0/elasticsearch-analysis-ik-8.12.0.zip 解压到ik目录下
unzip elasticsearch-analysis-ik-8.12.0.zip