【发布时间】:2018-01-18 15:57:55
【问题描述】:
我目前正在 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) 从我的机器终端运行 curl 也不会这样做。
我在这里缺少什么?
【问题讨论】:
-
如果你在 Mac 上使用 docker,docker 会在后台创建一个 linux VM 并在这个 VM 中运行容器。您需要获取 VM 的 IP 并启用到容器的端口转发。
-
@yamenK 我正在使用 Docker 创建的 VM 的 IP。仍然无法正常工作。我已经使用 docker -inspect
检查了它 -
这个答案可能会有所帮助:stackoverflow.com/questions/41752646/…
-
使用 inspect 命令显示的 docker 容器 IP 与 VM IP 不同。容器有一个私有虚拟网络。
-
你能帮我确定我在哪里可以获得虚拟机的 IP 地址吗?还没到那里...
标签: elasticsearch docker networking containers