2017-08-10 140 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名稱嗎? –

相關問題