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
相关推荐
IT利刃出鞘3 小时前
Docker Compose--安装WordPress--方法/示例
运维·docker·容器
Elastic 中国社区官方博客11 小时前
Elasticsearch 向量数据库:几分钟内完成部署,以经济高效的方式扩展至数千亿规模
大数据·运维·数据库·elasticsearch·搜索引擎·ai·全文检索
自律最差的编程狗12 小时前
Ubuntu下Docker部署Ollama 轻量模型
linux·ubuntu·docker
wdfk_prog12 小时前
大型 Docker 镜像导出导入工程化:可靠性、磁盘与压缩
运维·docker·容器
郝开13 小时前
Docker Compose 模块化多环境配置规范指南:示例搭建Alf Tengine MD2DOC 1.1.1
运维·docker·容器
Albart57513 小时前
Docker Desktop 增量更新失败终极排查:Failed to apply delta update 反复回滚怎么办?
windows·docker·容器·docker部署大模型
Elasticsearch14 小时前
将 Vercel 数据导入 Elastic:无需安装任何东西的无服务器可观测性
elasticsearch
sibylyue14 小时前
【云原生系列3】Docker Compose单机多容器编排工具
运维·docker·容器
java_logo15 小时前
Docker 部署 ArchivesSpace:轻松搭建档案信息管理平台
运维·docker·容器·档案管理·轩辕镜像·archivesspace·特藏