简体   繁体   English

Docker从主机访问elasticsearch端点

[英]Docker access elasticsearch endpoint from host

I'm running a docker image using the following command:我正在使用以下命令运行 docker 映像:

 docker run -P elasticsearch:2.2

I am able to access the http endpoint that runs on port 9200 from the host, however I'm unclear on how I can set the publish_address so that it doesn't keep changing.我能够从主机访问在端口 9200 上运行的 http 端点,但是我不清楚如何设置 publish_address 以便它不会不断变化。 I attempted to modify the elasticsearch.yml and set the network.publish property to the ip address assigned to docker0 and eth0 as well as lo and even though it confirms the binding in the output on startup, curling to the address gives me a connection refused.我试图修改 elasticsearch.yml 并将 network.publish 属性设置为分配给 docker0 和 eth0 以及 lo 的 ip 地址,即使它在启动时确认输出中的绑定,卷曲到地址给我一个连接被拒绝.

The following elasticsearch:2.2 expose some ports 9200 and 9300. Well known ports when you use Elasticsearch.下面的elasticsearch:2.2暴露了一些端口9200和9300。当你使用Elasticsearch时众所周知的端口。 Docker recommand to use the common, traditional port for your application which is what elasticsearch:2.2 did. Docker 建议为您的应用程序使用通用的传统端口,这正是 elasticsearch:2.2 所做的。 Don't modify the internal elasticsearch.yml;不要修改内部的elasticsearch.yml; Let it as it is :)就这样吧:)

The only thing to do is to map the image internal ports to ports from your host by using -p (lower case) option instead of -P (upper case)唯一要做的就是使用-p (小写)选项而不是-P (大写)将映像内部端口映射到主机的端口

Use it like this :像这样使用它:

docker run -p 9200:9200/tcp -p 9300:9300/tcp elasticsearch:2.2

Doing so you tell docker to not use a random port but to use those that you map to the internal ports by using -p option.这样做可以告诉 docker 不要使用随机端口,而是使用通过-p选项映射到内部端口的端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从主机访问在docker容器中运行的kibana Web UI和Elasticsearch - Unable to access kibana web UI and Elasticsearch running in docker container from host machine Docker 中的 Elasticsearch 没有到主机的路由 - Elasticsearch in Docker No route to host 无法从主机操作系统访问Vagrant VM中的Elasticsearch 2.0 - Cannot access Elasticsearch 2.0 in Vagrant VM from host OS 如何从Linux Guest(Virtualbox)到OSX Host访问elasticsearch? - How to access elasticsearch from Linux Guest (Virtualbox) to OSX Host? Elasticsearch 5.1和Docker - 如何正确配置网络以从主机访问Elasticsearch - Elasticsearch 5.1 and Docker - How to get networking configured properly to reach Elasticsearch from the host httpoison无法在docker环境中从webapp访问elasticsearch - httpoison cannot access elasticsearch from webapp in a docker environment 如何从外部访问存储在Docker容器中的Elasticsearch? - How to access an Elasticsearch stored in a Docker container from outside? 运行ElasticSearch的Docker的network.host设置 - network.host setting for Docker running ElasticSearch 将Dockerized Elasticsearch与多个Docker主机集群化 - Clustering Dockerized Elasticsearch with multiple Docker Host 如何在 AWS 中访问 ElasticSearch 域端点 URL? - How to access ElasticSearch domain endpoint URL in AWS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM