Docker搭建ElasticSearch开发环境
# 一、搭建ElasticSearch:7.10.1
1)docker pull image
$ docker pull elasticsearch:7.10.1
$ docker pull mobz/elasticsearch-head:5
$ docker pull kibana:7.10.1
1
2
3
2
3
2)create network
$ docker network create esnetwork
1
3)run elastic search
$ docker run -d --name elasticsearch --net esnetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.10.1
1
注意事项
- kibana的container共用elasticsearch的网络
- elasticsearch服务有跨域问题,导致elasticsearch-head无法连接到ES,因此需要进入ES容器修改配置
$ docker exec -it elasticsearch /bin/bash
[root@50652565b0fd elasticsearch]$ vi config/elasticsearch.yml
# 加入跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@50652565b0fd elasticsearch]$ docker restart elasticsearch
1
2
3
4
5
6
7
2
3
4
5
6
7
4)run kibana
$ docker run -d --name kibana --net esnetwork -p 5601:5601 kibana:7.10.1
1
5)run elasticsearch-head
$ docker run -it --name elasticsearch-head -d --net esnetwork -p 9100:9100 docker.io/mobz/elasticsearch-head:5
1
# 二、搭建ElasticSearch:6.7.2
1)docker pull image
$ docker pull elasticsearch:6.7.2
$ docker pull mobz/elasticsearch-head:5
$ docker pull kibana:6.7.2
1
2
3
2
3
2)run ES in docker
docker run -it --name elasticsearch -d -p 9200:9200 -p 9300:9300 -p 5601:5601 elasticsearch:6.7.2
1
注意事项
- kibana的container共用elasticsearch的网络
- elasticsearch服务有跨域问题,导致elasticsearch-head无法连接到ES,因此需要进入ES容器修改配置
$ docker exec -it elasticsearch /bin/bash
[root@50652565b0fd elasticsearch]$ vi config/elasticsearch.yml
# 加入跨域配置
http.cors.enabled: true
http.cors.allow-origin: "*"
[root@50652565b0fd elasticsearch]$ docker restart elasticsearch
1
2
3
4
5
6
7
2
3
4
5
6
7
3)run Kibana in docker
kibana的container共用elasticsearch的网络
$ docker run -it -d -e ELASTICSEARCH_URL=http://127.0.0.1:9200 --name kibana --network=container:elasticsearch kibana:6.7.2
1
4)run elasticsearch-head in docker
$ docker run -it --name elasticsearch-head -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5
1
上次更新: 2021/01/18, 10:01:00