- docker pull 镜像, 可用镜像查看hub.docker.com: https://hub.docker.com/
[root@localhost ~]# docker pull elasticsearch:7.6.1
-
创建elasticsearch的plugins目录和data目录:/data/docker/elasticsearch/data, /data/docker/elasticsearch/plugins
-
运行
[root@localhost elasticsearch]# sudo docker run -p 9200:9200 -p 9300:9300 --name elasticsearch7 \
-e "discovery.type=single-node" -e "cluster.name=elasticsearch" \
-v /data/docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-v /data/docker/elasticsearch/data:/usr/share/elasticsearch/data \
-d --restart=always elasticsearch:7.6.1
- 验证
[root@0453b61be4fe elasticsearch]# curl -XGET 'localhost:9200'
{
"name" : "0453b61be4fe",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "G9-eDiCGQz-zeoDcKymiqw",
"version" : {
"number" : "7.6.1",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
"build_date" : "2020-02-29T00:15:25.529771Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
即表示成功
- 进入elasticsearch 容器
[root@localhost elasticsearch]# docker exec -it elasticsearch7 /bin/bash
- 部署elasticsearch-head
6.1 拉取镜像
6.2 运行容器[root@localhost elasticsearch]# docker pull mobz/elasticsearch-head:5
6.3 修改elasticsearch的跨域配置,不修改的话elasticsearch-head无法连接, 进入elasticsearch 容器,修改/usr/share/elasticsearch/config/elasticsearch.yml,增加配置如下:[root@localhost elasticsearch]# docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
6.4 打开elasticsearch-head页面:http://ip:9100,连接http://ip:9200,即可看到如下界面http.cors.enabled: true http.cors.allow-origin: ''