注意es不支持直接映射对应目录
version: "3"
networks:
x-net:
driver: bridge
name: docker.x.com
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.12
restart: always
container_name: elasticsearch
environment:
- TZ=Asia/Shanghai
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- jdx-net
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:6.8.12
restart: always
container_name: elasticsearch2
environment:
- TZ=Asia/Shanghai
- cluster.name=docker-cluster
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "discovery.zen.ping.unicast.hosts=elasticsearch"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
- x-net
es-head:
image: tobias74/elasticsearch-head
ports:
- 9100:9100
environment:
- TZ=Asia/Shanghai
container_name: es-head
restart: always
#network_mode: "host"
networks:
- x-net
volumes:
esdata1:
driver: local
esdata2:
driver: local
参考文档
官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docker.html
Elasticsearch docker部署单机集群:https://blog.csdn.net/supahero/article/details/110670430
centos利用docker-compose安装单节点elasticsearch 7.7.0:https://blog.csdn.net/ZHONGZEWEI/article/details/106871136