先安装一个单机版 【单机版本参考
复制容器配置文件 (执行三份)
docker cp es:/usr/share/elasticsearch/config /dp/vm/es1
创建目录 /dp/vm/es1/data  /dp/vm/es1/plugins /dp/vm/es1/logs
设置权限chmod 777 /dp/vm/es1/*

启动容器

docker run -d \
--name=es1 \
--restart=always \
--network es-net \
-p 9201:9200 \
-p 9301:9300 \
-v /dp/docker/file/es1/plugins:/usr/share/elasticsearch/plugins \
-v /dp/docker/file/es1/data:/usr/share/elasticsearch/data \
-v /dp/docker/file/es1/config:/usr/share/elasticsearch/config \
-v /dp/docker/file/es1/logs:/usr/share/elasticsearch/logs \
-e node.name=es1 \
-e node.roles=[master] \
-e network.host=es1 \
-e discovery.seed_hosts=es1,es2,es3 \
-e cluster.initial_master_nodes=es1 \
-e cluster.name=dp-cluster \
-e "ES_JAVA_OPTS=-Xms8192m -Xmx8192m" \
--privileged \
es:8.7.0

docker run -d \
--name=es2 \
--restart=always \
--network es-net \
-p 9202:9200 \
-p 9302:9300 \
-v /dp/docker/file/es2/plugins:/usr/share/elasticsearch/plugins \
-v /dp/docker/file/es2/data:/usr/share/elasticsearch/data \
-v /dp/docker/file/es2/config:/usr/share/elasticsearch/config \
-v /dp/docker/file/es2/logs:/usr/share/elasticsearch/logs \
-e node.name=es2 \
-e node.roles=[data] \
-e network.host=es2 \
-e discovery.seed_hosts=es1,es2,es3 \
-e cluster.initial_master_nodes=es1 \
-e cluster.name=dp-cluster \
-e "ES_JAVA_OPTS=-Xms8192m -Xmx8192m" \
--privileged \
es:8.7.0

docker run -d \
--name=es3 \
--restart=always \
--network es-net \
-p 9203:9200 \
-p 9303:9300 \
-v /dp/docker/file/es3/plugins:/usr/share/elasticsearch/plugins \
-v /dp/docker/file/es3/data:/usr/share/elasticsearch/data \
-v /dp/docker/file/es3/config:/usr/share/elasticsearch/config \
-v /dp/docker/file/es3/logs:/usr/share/elasticsearch/logs \
-e node.name=es3 \
-e node.roles=[data] \
-e network.host=es3 \
-e discovery.seed_hosts=es1,es2,es3 \
-e cluster.initial_master_nodes=es1 \
-e cluster.name=dp-cluster \
-e "ES_JAVA_OPTS=-Xms8192m -Xmx8192m" \
--privileged \
es:8.7.0


启动一个默认容器复制配置文件
docker cp kibana1:/usr/share/kibana/config /dp/vm/kibana1

修改其中的 elasticsearch.hosts: [ "http://es1:9200" ,"http://es2:9200" ,"http://es3:9200" ]

docker run -d \
--name kibana1 \
-v /dp/vm/kibana1/config/kibana.yml:/usr/share/kibana/config/kibana.yml \
--network=es-net \
-p 5601:5601\
kibana:8.7.0