elasticsearch - 如何从外部访问存储在Docker容器中的Elasticsearch?

标签 elasticsearch docker networking containers

我目前正在Docker容器中运行Elasticsearch(ES)5.5。 (见下文)

curl -XGET 'localhost:9200'
{
  "name" : "THbbezM",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "CtYdgNUzQrS5YRTRT7xNJw",
  "version" : {
    "number" : "5.5.0",
    "build_hash" : "260387d",
    "build_date" : "2017-06-30T23:16:05.735Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.0"
  },
  "tagline" : "You Know, for Search"
}

我已将elasticsearch.yml文件更改为如下所示:
http.host: 0.0.0.0

# Uncomment the following lines for a production cluster deployment
#transport.host: 0.0.0.0
#discovery.zen.minimum_master_nodes: 1

network.host: 0.0.0.0
http.port: 9200

我目前可以通过curl -XGET命令获取索引。这里的问题是,我希望能够使用它的Ip地址而不是从我的机器(Mac OS X)开始的'localhost:9200'设置向该ES实例发出http请求。

所以,我已经尝试过了:

1)我尝试在Postman中进行以下操作:
Could not get any response
There was an error connecting to X.X.X.X:9200/.
Why this might have happened:
The server couldn't send a response:
Ensure that the backend is working properly
Self-signed SSL certificates are being blocked:
Fix this by turning off 'SSL certificate verification' in Settings > General
Client certificates are required for this server:
Fix this by adding client certificates in Settings > Certificates
Request timeout:
Change request timeout in Settings > General

2)我也在Sense(Chrome插件)中尝试过:
Request failed to get to the server (status code: 0):

3)从机器的终端运行卷发也不会这样做。

我在这里想念什么?

最佳答案

Docker for Mac提供了可以使用的DNS名称:
docker.for.mac.localhost

关于elasticsearch - 如何从外部访问存储在Docker容器中的Elasticsearch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45613072/

相关文章:

docker - 如何 "reset"docker-compose systemd 服务?

docker - 如何在不使用Docker Hub的情况下将应用程序部署到容器OS?

java - ObjectOutputStream 被击中

java - 使用 Java API 获取 Elasticsearch 版本

elasticsearch - 从Elasticsearch的基本术语聚合中删除停用词?

elasticsearch - 在索引类型的映射中更改属性的类型

Django REST API 设置允许单个端点的主机

azure - 将 VNET 移至新的 RG,但 AKS 仍指向旧的 RG

windows - 如何在 Windows 7/Vista 上以编程方式挂载 WebDAV 共享而不分配驱动器号?

elasticsearch - 从kafka导入数据到Elasticsearch时如何获取导入进度和错误日志?