2017-08-10 98 views
0

我目前在Docker容器中运行Elasticsearch(ES)5.5。 (见下文)如何从外部访问存储在Docker容器中的Elasticsearch?

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 

我目前通过卷曲-XGET命令让我的索引。这里的事情是,我希望能够使用它的Ip地址,而不是从我的机器(Mac OS X)开始的'localhost:9200'设置,对这个ES实例执行http请求。

所以,我已经试过不已:

1)我试着做它在邮差得到以下回应:

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)我也试过在检测(插件Chrome浏览器):

Request failed to get to the server (status code: 0): 

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

我在这里错过了什么?

+0

如果您使用的是Mac上的码头工人,码头工人在后台创建一个Linux虚拟机并运行该虚拟机内部的容器。您需要获取VM的IP并启用端口转发到您的容器。 – yamenk

+0

@yamenK我正在使用Docker创建的虚拟机的IP。反正仍然没有工作。我使用docker -inspect来检查它

+0

这个答案可能有所帮助:https://stackoverflow.com/questions/41752646/elasticsearch-5-1-and-docker-how-to-get-networking-configured-正确地反应/ 45549124#45549124 – Val

回答

0

泊坞窗为Mac提供了DNS名称可以使用:

docker.for.mac.localhost

+0

指定绑定主机时,我应该在elasticsearch.yml中使用该DNS名称吗? –

相关问题