第一步 docker pull elasticsearch:7.17.5
在宿主机常见目录和文件,然后启动时关联
yml文件配置
cluster.name: "docker-cluster"
network.host: 0.0.0.0
#network.host: 192.168.0.5
#http.port: 9200
#添加配置
http.cors.enabled: true
http.cors.allow-origin: "*"
#http.cors.allow-headers: Authorization
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: "X-Requested-With,X-Auth-Token,Content-Type, Content-Length, Authorization"
discovery.zen.minimum_master_nodes: 1
#开启安全选项
xpack.security.enabled: true
#配置单节点模式
discovery.type: single-node
启动命令:
docker run --restart=always -p 9200:9200 -p 9300:9300 -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -v /Users/。。。/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /Users/。。。/elasticsearch/data:/usr/share/elasticsearch/data -v /Users/。。。/elasticse