1、拉取镜像
$ docker image pull elasticsearch:6.8.8
2、运行容器
ElasticSearch的默认端口是9200,我们把宿主环境9200端口映射到Docker容器中的9200端口,就可以访问到Docker容器中的ElasticSearch服务了,同时我们把这个容器命名为es。
$ docker run -d --name es -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:6.8.8
3、此时访问 192.168.99.100:9200后,返回
{ name: "aRjAteV", cluster_name: "docker-cluster", cluster_uuid: "ncYBy862QTyg57FgKAxmTw", version: { number: "6.8.8", build_flavor: "default", build_type: "docker", build_hash: "2f4c224", build_date: "2020-03-18T23:22:18.622755Z", build_snapshot: false, lucene_version: "7.7.2", minimum_wire_compatibility_version: "5.6.0", minimum_index_compatibility_version: "5.0.0" }, tagline: "You Know, for Search" }
说明 ElasticSearch 已启动。