docker elasticsearch but could not connect to it at its publish address of

{"@timestamp":"2024-11-28T13:19:51.860Z", "log.level": "WARN", "message":"Successfully discovered master-eligible node {es0011}{FKHz7aIYQkeHqyD-yU3SZg}{dDTB3lswQZeX7UcqCYURjA}{es0011}{192.168.32.2}{192.168.32.2:9300}{cdfhilmrstw}{8.16.0}{7000099-8518000} at address 192.168.0.15:9300 but could not connect to it at its publish address of 192.168.32.2:9300. Each node in a cluster must be accessible at its publish address by all other nodes in the cluster. See https://www.elastic.co/guide/en/elasticsearch/reference/8.16/modules-network.html#modules-network-binding-publishing for more information.", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearches0031genericT#1","log.logger":"org.elasticsearch.discovery.HandshakingTransportAddressConnector","elasticsearch.node.name":"es0031","elasticsearch.cluster.name":"tsc","error.type":"org.elasticsearch.transport.ConnectTransportException","error.message":"es0011192.168.32.2:9300 connect_timeout30s","error.stack_trace":"org.elasticsearch.transport.ConnectTransportException: es0011192.168.32.2:9300 connect_timeout30s\n\tat org.elasticsearch.server@8.16.0/org.elasticsearch.transport.TcpTransportChannelsConnectedListener.onTimeout(TcpTransport.java:1151)\\n\\tat org.elasticsearch.server@8.16.0/org.elasticsearch.common.util.concurrent.ThreadContextContextPreservingRunnable.run(ThreadContext.java:956)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1575)\n"}

{"@timestamp":"2024-11-28T13:19:58.837Z", "log.level": "WARN", "message":"master not discovered yet, this node has not previously joined a bootstrapped cluster, and this node must discover master-eligible nodes es0011, es0012 to bootstrap a cluster: have discovered {es0031}{URFt4pBHR8m62zXmtfsJFg}{43qVd3RPRFeIfQcNDPXzRQ}{es0031}{172.19.0.3}{172.19.0.3:9300}{cdfhilmrstw}{8.16.0}{7000099-8518000}; discovery will continue using 192.168.0.15:9300, 192.168.0.15:9301 from hosts providers and {es0031}{URFt4pBHR8m62zXmtfsJFg}{43qVd3RPRFeIfQcNDPXzRQ}{es0031}{172.19.0.3}{172.19.0.3:9300}{cdfhilmrstw}{8.16.0}{7000099-8518000} from last-known cluster state; node term 0, last-accepted version 0 in term 0; for troubleshooting guidance, see https://www.elastic.co/guide/en/elasticsearch/reference/8.16/discovery-troubleshooting.html", "ecs.version": "1.2.0","service.name":"ES_ECS","event.dataset":"elasticsearch.server","process.thread.name":"elasticsearches0031cluster_coordinationT#1","log.logger":"org.elasticsearch.cluster.coordination.ClusterFormationFailureHelper","elasticsearch.node.name":"es0031","elasticsearch.cluster.name":"tsc"}

解决办法: 在 docker-compose.yml 文件中增加

复制代码
environment: 
   network.publish_host=希望别人知道的ip,而不是容器内的ip

另外要注意的是 在docker容器中启动时, 端口也要设置跟宿主机的一样

复制代码
- http.port=9201
- transport.port=9301
相关推荐
天外天-亮11 小时前
docker + window 安装
运维·docker·容器
进击的小菜鸡dd11 小时前
docker 容器的挂载映射关系查看
运维·docker·容器
程序员梅雨11 小时前
微服务学习最终篇: Elasticsearch
学习·elasticsearch·微服务
Elasticsearch11 小时前
教程:使用 ES|QL 进行威胁狩猎
elasticsearch
程序员老赵12 小时前
Docker 部署 TeX Live:轻松搭建 LaTeX 论文排版编译平台
前端·docker·latex
陈皮糖..12 小时前
基于 Keepalived 的传统 Web 高可用架构的容器化改造与可观测性升级
运维·docker·性能优化·架构·云计算·prometheus
秦jh_12 小时前
222222
docker
java_logo12 小时前
Docker 部署 go2rtc:轻松搭建摄像头多协议流媒体平台
运维·docker·容器·摄像头·rtsp·轩辕镜像·go2rtc
智搜广告13 小时前
GEO优化公司怎么选?智搜广告从三个维度帮你判断
大数据·人工智能·python·elasticsearch·microsoft·geo
Elastic 中国社区官方博客13 小时前
Elasticsearch:ES|QL 搜索教程
大数据·数据库·人工智能·sql·elasticsearch·搜索引擎·全文检索