本地启动Elasticsearch(docker启动)

一、es版本7.17.0

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d --name ES01 elasticsearch:7.17.0

进入容器,修改/usr/share/elasticsearch/config/elasticsearch.yml
添加如下数据

http.cors.enabled : true
http.cors.allow-origin : "*"

拷贝出来

docker cp ES01:/usr/share/elasticsearch/config/elasticsearch.yml /Users/xxxxx/data

删除容器重新启动

docker run -v /Users/xxxxx/data/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" -d --name ES01 elasticsearch:7.17.0

二、elasticsearch-head

docker run -d -p 9100:9100 docker.io/mobz/elasticsearch-head:5

拷贝文件vendor.js

docker cp 容器id:/usr/src/app/_site/vendor.js /Users/xxxxx/data

修改以下2处

  1. 将 6886行 contentType: “application/x-www-form-urlencoded” 修改为 contentType: “application/json;charset=UTF-8”
  2. 然后再将 7574行 var inspectData = s.contentType === “application/x-www-form-urlencoded” && 修改为 var inspectData = s.contentType === “application/json;charset=UTF-8” &&

删除容器,再次启动,将vendor.js 文件挂载进去

docker run -d -p 9100:9100 -v /Users/xxxxxx/data/vendor.js:/usr/src/app/_site/vendor.js docker.io/mobz/elasticsearch-head:5

参考文章:
https://cloud.tencent.com/developer/article/1661930
https://blog.csdn.net/catoop/article/details/103737698

你可能感兴趣的:(elasticsearch,docker)