1.拉取镜像

  1. docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.2

2.启动es

  1. 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.进入容器,配置跨域

  1. docker exec -it es /bin/bash
  2. # 显示文件
  3. ls
  4. 结果如下:
  5. LICENSE.txt README.textile config lib modules
  6. NOTICE.txt bin data logs plugins
  7. # 进入配置文件夹
  8. cd config
  9. # 显示文件
  10. ls
  11. 结果如下:
  12. elasticsearch.keystore ingest-geoip log4j2.properties roles.yml users_roles
  13. elasticsearch.yml jvm.options role_mapping.yml users
  14. # 修改配置文件
  15. vi elasticsearch.yml
  16. # 加入跨域配置
  17. http.cors.enabled: true
  18. http.cors.allow-origin: "*"

4.重启容器

  • 由于修改了配置,因此需要重启ElasticSearch容器。

    1. docker restart es

    5. Docker 部署 ElasticSearch-Head

  • 拉取镜像

    1. docker pull mobz/elasticsearch-head:5
  • 运行容器

    1. docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
  • 访问后台

b17df8394aa5a7b17276ed09b3bf1bc.png

6.打完收工