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":"elasticsearch[es0031][generic][T#1]","log.logger":"org.elasticsearch.discovery.HandshakingTransportAddressConnector","elasticsearch.node.name":"es0031","elasticsearch.cluster.name":"tsc","error.type":"org.elasticsearch.transport.ConnectTransportException","error.message":"[es0011][192.168.32.2:9300] connect_timeout[30s]","error.stack_trace":"org.elasticsearch.transport.ConnectTransportException: [es0011][192.168.32.2:9300] connect_timeout[30s]\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":"elasticsearch[es0031][cluster_coordination][T#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
相关推荐
豆芽脚脚3 分钟前
docker compose再阿里云上无法使用的问题
阿里云·docker·容器
十行代码九行报错2 小时前
Docker基础学习笔记
笔记·学习·docker
2501_9301040411 小时前
GitCode 疑难问题诊疗:全方位指南
大数据·elasticsearch·gitcode
健康平安的活着11 小时前
es7.17.x es服务yellow状态的排查&查看节点,分片状态数量
大数据·elasticsearch·搜索引擎
Agome9914 小时前
Docker之自定义jkd镜像上传阿里云
阿里云·docker·容器
无能百分百14 小时前
阿里云服务器ECS安装Docker(CentOS 7.x)
docker
Elasticsearch1 天前
Elastic 的托管 OTLP 端点:为 SRE 提供更简单、可扩展的 OpenTelemetry
elasticsearch
天上掉下来个程小白1 天前
Docker-14.项目部署-DockerCompose
运维·docker·微服务·容器
Yusei_05231 天前
迅速掌握Git通用指令
大数据·git·elasticsearch
星霜笔记1 天前
Docker 部署 MariaDB+phpMyAdmin+Nextcloud 完整教程
运维·数据库·docker·容器·mariadb