1.拉取镜像
docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.2
2.运行容器
docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.2
3.进入容器并修改配置
docker exec -it es /bin/bash
cd config
vi elasticsearch.yml
cluster.name: "docker-cluster" network.host: 0.0.0.0 # minimum_master_nodes need to be explicitly set when bound on a public IP # set to 1 to allow single node clusters # Details: https://github.com/elastic/elasticsearch/pull/17288 discovery.zen.minimum_master_nodes: 1
4.重启容器
docker restart es
5.查看容器是否启动成功,显示如下表示启动成功
http://ip:9200/
{ "name" : "C9GtLXP", "cluster_name" : "docker-cluster", "cluster_uuid" : "jqB6ru-vS82x9dMmA7B-lA", "version" : { "number" : "6.3.2", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "053779d", "build_date" : "2018-07-20T05:20:23.451332Z", "build_snapshot" : false, "lucene_version" : "7.3.1", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" }
6.springboot连接环境与配置
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency>
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes = 192.168.94.135:9300
7.常见错误
https://blog.csdn.net/weixin_39902472/article/details/111037048