首先下载elasticsearch镜像
docker pull elasticsearch:6.7.0
编写Dockerfile
Dockerfile的内容如下,已经有了详细注释就不再赘述了:
FROM elasticsearch:6.7.0
# 注意 es与ik 版本要对应
RUN ./bin/elasticsearch-plugin install --batch https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.7.0/elasticsearch-analysis-ik-6.7.0.zip
构建镜像
在Dockerfile所在目录执行以下命令即可构建镜像:
docker build -t elasticsearch_ik .
安装Kibana
安装
docker run -it -d -e ELASTICSEARCH_URL=http://172.17.0.2:9200 --name kibana -p 5601:5601 kibana:5.6.11
注意:es 的 URL要写容器内部的ip,查看容器内部的ip命令:
docker inspect --format ‘{{ .NetworkSettings.IPAddress }}’
或
docker inspect
验证
访问 http://localhost:5601
如果上面启动kibana不能连接elasticsearch换另一只方式启动kibana
[root@localhost es]# docker exec -it kibana /bin/bash
bash-4.2$ ll
bash: ll: command not found
bash-4.2$ ls
LICENSE.txt NOTICE.txt README.txt bin built_assets config data node node_modules optimize package.json plugins src target webpackShims
bash-4.2$ cd config/
bash-4.2$ ls
kibana.yml
bash-4.2$ vi kibana.yml
bash-4.2$ vi kibana.yml
bash-4.2$ exit
exit
[root@localhost es]# docker restart kibana
修改kibana.yml
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://172.17.0.2:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true