拉取镜像
docker pull elasticsearch
启动
创建网络
docker network create somenetwork
启动
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch
不自建网络
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch
加上目录映射启动
/usr/share/elasticsearch
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v $PWD/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v $PWD/elasticsearch/data:/usr/share/elasticsearch/data elasticsearch
注意$PWD/elasticsearch/config/elasticsearch.yml 文件需要先创建,不然会失败
宿主机无法访问
http.cors.enabled: true
http.cors.allow-origin: "*"
#添加如下配置
network.host: 0.0.0.0
http.port: 9200
transport.host: localhost
transport.tcp.port: 9300
配置后重启
docker restart elasticsearch
安装elasticsearch-head
docker pull mobz/elasticsearch-head:5
docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5