5.6.10

Elastic 版本:5.6.10 官方教程

  1. docker pull docker.elastic.co/elasticsearch/elasticsearch:5.6.10
  2. # 开发模式下快速启动一个 elastic
  3. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:5.6.10
  4. # 创建数据卷
  5. docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v elasticdata:/usr/share/elasticsearch/data --privileged -v full_path_to/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml docker.elastic.co/elasticsearch/elasticsearch:5.6.10
  • 第一个 -v 挂载了一个卷:数据目录存储
  • 第二个 -v 挂载了本地的一个文件:elastic 的配置文件

使用 docker-compose,docker-compose.yml

  1. services:
  2. elasticsearch:
  3. image: docker.elastic.co/elasticsearch/elasticsearch:5.6.10
  4. container_name: elasticsearch
  5. environment:
  6. - cluster.name=docker-cluster
  7. - bootstrap.memory_lock=true
  8. volumes:
  9. - esdata:/usr/share/elasticsearch/data
  10. - ./custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  11. ports:
  12. - 9200:9200
  13. - 9300:9300
  14. volumes:
  15. esdata:
  16. driver: local

custom_elasticsearch.yml

  1. discovery:
  2. type: single-node # 单节点模式
  3. network:
  4. host: 0.0.0.0 # 开放远程访问
  5. xpack:
  6. security:
  7. enabled: false # 关闭用户名密码保护

6.6.0

docker-compose.yml

  1. elasticsearch6.6.0:
  2. image: docker.elastic.co/elasticsearch/elasticsearch:6.6.0
  3. container_name: elasticsearch_660
  4. environment:
  5. - cluster.name=docker-cluster
  6. - bootstrap.memory_lock=true
  7. volumes:
  8. - ./elasticsearch6.6.0/data:/usr/share/elasticsearch/data
  9. - ./elasticsearch6.6.0/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  10. ports:
  11. - 9200:9200
  12. - 9300:9300

custom_elasticsearch.yml

  1. discovery:
  2. type: single-node # 单节点模式
  3. network:
  4. host: 0.0.0.0 # 开放远程访问
  5. # 外部访问 es 时使用的 IP 地址,如果不配置,会自动选择其中一张网卡的地址,有可能就选择错了网卡地址,导致你本机通过发布的地址也访问不了 es
  6. # 查看该地址可以使用 http://127.0.0.1:9200/_nodes/http?pretty 查看
  7. publish_host: 127.0.0.1
  8. xpack:
  9. security:
  10. enabled: false # 关闭用户名密码保护

启动后访问:http://localhost:9200/ 能看到 Elasticsearch 的版本等信息返回

可以访问 http://127.0.0.1:9200/_nodes/http?pretty 查看节点状态信息

  1. {
  2. "_nodes": {
  3. "total": 1,
  4. "successful": 1,
  5. "failed": 0
  6. },
  7. "cluster_name": "docker-cluster",
  8. "nodes": {
  9. "vpS-dFp8SJe73RKL_ylVnw": {
  10. "name": "vpS-dFp",
  11. "transport_address": "127.0.0.1:9300",
  12. "host": "127.0.0.1",
  13. "ip": "127.0.0.1",
  14. "version": "6.6.0",
  15. "build_flavor": "default",
  16. "build_type": "tar",
  17. "build_hash": "a9861f4",
  18. "roles": [
  19. "master",
  20. "data",
  21. "ingest"
  22. ],
  23. "attributes": {
  24. "ml.machine_memory": "2082197504",
  25. "xpack.installed": "true",
  26. "ml.max_open_jobs": "20",
  27. "ml.enabled": "true"
  28. },
  29. "http": {
  30. "bound_address": [
  31. "0.0.0.0:9200"
  32. ],
  33. "publish_address": "127.0.0.1:9200",
  34. "max_content_length_in_bytes": 104857600
  35. }
  36. }
  37. }
  38. }

7.17.6

7.17.6

docker-compose.yml

  1. version: "3.9"
  2. services:
  3. es:
  4. image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
  5. container_name: es
  6. environment:
  7. - TZ=Asia/Shanghai
  8. - node.name=es01
  9. - cluster.name=es-docker-cluster
  10. - bootstrap.memory_lock=true
  11. volumes:
  12. - ./elasticsearch/data:/usr/share/elasticsearch/data
  13. - ./elasticsearch/custom_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
  14. ports:
  15. - 9200:9200
  16. - 9300:9300

custom_elasticsearch.yml

  1. discovery:
  2. type: single-node # 单节点模式
  3. network:
  4. host: 0.0.0.0 # 开放远程访问
  5. # 外部访问 es 时使用的 IP 地址,如果不配置,会自动选择其中一张网卡的地址,有可能就选择错了网卡地址,导致你本机通过发布的地址也访问不了 es
  6. # 查看该地址可以使用 http://127.0.0.1:9200/_nodes/http?pretty 查看
  7. publish_host: 127.0.0.1
  8. xpack:
  9. security:
  10. enabled: false # 关闭用户名密码保护