快速上手 Elasticsearch:Docker Compose 部署详解
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.10.0
container_name: elasticsearch
environment:
- network.host=0.0.0.0
- cluster.name=docker-cluster
- discovery.type=single-node
volumes:
- type: bind
source: ./elasticsearch.yml
target: /usr/share/elasticsearch/config/elasticsearch.yml
- type: bind
source: ./data
target: /usr/share/elasticsearch/data
ports:
- "9200:9200"
- "9300:9300"
healthcheck:
test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
interval: 30s
timeout: 10s
retries: 5
这个Docker Compose文件定义了一个单节点Elasticsearch集群。它将Elasticsearch配置文件挂载到服务的elasticsearch.yml
,同时将数据卷挂载到容器的data
目录。它还暴露了Elasticsearch的默认端口9200和9300,这是Elasticsearch节点之间通信所使用的端口。最后,它配置了一个健康检查,以确保Elasticsearch服务在启动之前就绪。
评论已关闭