1.安装版本
- Elasticsearch(8.18.3)
- kibana(8.18.3)
- ik分词器(8.18.3)
2.创建网络,让ES与Kibana容器互联
docker network create es-net
3.加载镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.18.3
sudo docker pull docker.elastic.co/kibana/kibana:8.18.3
4.运行ES容器
找到你想存放的目录
mkdir -p /app/nova_office/elasticsearch/{data,plugins,logs}
chown -R 1000:1000 /app/nova_office/elasticsearch # 重要!确保容器内的 elasticsearch 用户有权限访问
chmod -R 755 /app/nova_office/elasticsearch
#(有认证 + TLS))
docker run -d \
--name elasticsearch \
--restart=unless-stopped \
-e "ES_JAVA_OPTS=-Xms2g -Xmx2g" \
-e "discovery.type=single-node" \
-e "http.host=0.0.0.0" \
-v /app/nova_office/elasticsearch/data:/usr/share/elasticsearch/data \
-v /app/nova_office/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /app/nova_office/elasticsearch/logs:/usr/share/elasticsearch/logs \
--network es-net \
-p 9200:9200 \
-p 9300:9300 \
docker.elastic.co/elasticsearch/elasticsearch:8.18.3
# (无认证 + 无 TLS)
docker run -d \
--name elasticsearch \
--restart=unless-stopped \
-e ES_JAVA_OPTS="-Xms2g -Xmx2g" \
-e discovery.type=single-node \
-e http.host=0.0.0.0 \
-e xpack.security.enabled=false \
-e xpack.security.http.ssl.enabled=false \
-v /app/nova_office/elasticsearch/data:/usr/share/elasticsearch/data \
-v /app/nova_office/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /app/nova_office/elasticsearch/logs:/usr/share/elasticsearch/logs \
--network es-net \
-p 9200:9200 -p 9300:9300 \
docker.elastic.co/elasticsearch/elasticsearch:8.18.3
ES_JAVA_OPTS=-Xms2g -Xmx2g根据实际环境选择
sudo netstat -tulnp | grep -E "9200|9300"
sudo ufw allow 9200/tcp
sudo ufw allow 9300/tcp
5.运行Kibana
#(有认证 + TLS))
docker run -d \
--name kibana \
--restart=unless-stopped \
-e ELASTICSEARCH_HOSTS=http://192.168.20.101:9200 \
--network=es-net \
-p 5601:5601 \
docker.elastic.co/kibana/kibana:8.18.3
#(无认证 + 无 TLS)
docker run -d \
--name kibana \
--restart=unless-stopped \
-e ELASTICSEARCH_HOSTS=http://192.168.20.101:9200 \
--network=es-net \
-p 5601:5601 \
docker.elastic.co/kibana/kibana:8.18.3
sudo ufw allow 5601/tcp
6.安装IK分词器
#进入es容器
docker exec -it elasticsearch bash
#创建tmp
mkdir tmp
#进入tmp
cd tmp
#下载分词器
curl -L -o elasticsearch-analysis-ik-8.18.3.zip https://release.infinilabs.com/analysis-ik/stable/elasticsearch-analysis-ik-8.18.3.zip
#解压
unzip elasticsearch-analysis-ik-8.18.3.zip -d ../plugins/ik
#退出
exit
7.找到Kibana.yml
find / -name kibana.yml
vim /var/lib/docker/overlay2/a019fc10c87012f9101197046d05694bb01e1654a0bdd2ff9ab92ec513d32e3c/diff/usr/share/kibana/config/kibana.yml
#其中一个文件里面有,需要配置
server.host: "0.0.0.0"
server.shutdownTimeout: "5s"
elasticsearch.hosts: [ "http://127.0.0.1:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
i18n.locale: "zh-CN"
8.docker重启Kibana和 elasticsearch,浏览器打开 http://服务器ip:5601
docker restart elasticsearch
docker restart kibana
9.登录验证
进入 Elasticsearch,就会看到一个token令牌,复制配置
docker exec -it elasticsearch bash cd bin/ elasticsearch-create-enrollment-token --scope kibana
进入 Kibana,就会看到验证码
docker exec -it kibana bash cd bin/ kibana-verification-code
✅ 无认证这样就可以直接从浏览器访问:
- Elasticsearch:
http://192.168.20.101:9200
- Kibana:
http://192.168.20.101:5601
不再有登录密码,也不会有 HTTPS 证书警告。
✅ 方案二:使用可信的 HTTPS 证书(生产环境推荐)
如果你打算在公网部署,且希望保留 HTTPS 安全访问,你应该:
- 配置 Nginx 或 Traefik 作为反向代理
- 给它配置 Let’s Encrypt 免费证书(可信)
- 外部用户访问的是
https://your-domain.com
,证书自动信任,无警告 - 内部 Kibana / Elasticsearch 使用 HTTP 协议即可
✅ 这是生产环境标准做法:
🔒 外部 HTTPS,内部 HTTP,证书自动更新,用户无感知。