简体   繁体   English

使用Docker在Azure VM上运行Elasticsearch:无法通过本地主机访问

[英]Running elasticsearch on Azure VM using Docker: cannot access via localhost

I am new to both elasticsearch and VMs (i'm a data analyst, but I gotta set elasticsearch up on out azure cloud so as to do analysis later); 我对Elasticsearch和VM都是陌生的(我是数据分析师,但我必须在Azure云上设置Elasticsearch以便以后进行分析); so pardon me if my question is stupid. 如果我的问题很愚蠢,请原谅我。 I installed the Docker container for elasticsearch available from Azure marketplace. 我安装了可从Azure市场获得的用于Elasticsearch的Docker容器。 Elastcsearch is up and running and pinging the assigned IP is returning expected rsults like this: Elastcsearch已启动并正在运行,并且对分配的IP执行ping操作将返回预期结果,如下所示:

~$ curl 172.xx.x.x:9200
{
  "status" : 200,
  "name" : "Black Crow",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.7.1",
    "build_hash" : "b88f43fc40b0bcd7f173a1f9ee2e97816de80b19",
    "build_timestamp" : "2015-07-29T09:54:16Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.4"
  },
  "tagline" : "You Know, for Search"
}

I have also downloaded the "head" plugin for testing development on the VM. 我还下载了“ head”插件,用于在VM上测试开发。 However I am not able to run it on localhost:9200 . 但是我不能在localhost:9200上运行它。

~$ curl localhost:9200 gives: curl: (7) Failed to connect to localhost port 9200: Connection refused EDIT: Working now after adding -p flag to bind localhost's 9200 to vm's 9200. But still running localhost:9200 on browser doesnt connect. ~$ curl localhost:9200提供:curl:(7)无法连接到localhost端口9200:连接被拒绝编辑:添加-p标志将localhost的9200绑定到vm的9200之后,现在可以工作。但是在浏览器上仍运行localhost:9200却无法连接。 Supossedly the ip is undiscoverable. 可能是IP无法发现。 How to make it discoverable? 如何使其可发现?

I tried something like docker run -d -p 9200:9200 -p 9300:9300 -v $HOME/data:/data elasticsearch /elasticsearch/bin/elasticsearch (modified from http://www.codedependant.net/2015/01/17/install-elastic-search-plugins-through-docker/ ) but it doesn't work. 我尝试了类似docker run -d -p 9200:9200 -p 9300:9300 -v $ HOME / data:/ data elasticsearch / elasticsearch / bin / elasticsearch之类的东西(从http://www.codedependant.net/2015/01修改/ 17 / install-elastic-search-plugins-through-docker / ),但不起作用。

My $Home directory looks like this: 我的$ Home目录如下所示:

ls $HOME/*
/home/company/wget-log

/home/company/config:

/home/company/data:
elasticsearch.yml  plugins

/home/company/es:
plugins

(this folder above contains the plugins, not the other "plugins" folder in /data) (上面的此文件夹包含插件,而不是/ data中的其他“ plugins”文件夹)

/home/company/esdata:
elasticsearch

Any help will be appreciated. 任何帮助将不胜感激。 Thanks a lot 非常感谢

So, you mention a browser. 因此,您提到了浏览器。 Usually you run a browser from your local machine. 通常,您从本地计算机运行浏览器。 In that case, on a Windows 10 machine, 'localhost' will never resolve to a Docker container. 在这种情况下,在Windows 10计算机上,“ localhost”将永远不会解析为Docker容器。 Your docker container cannot run directly on windows, so must be running somewhere else. 您的Docker容器无法直接在Windows上运行,因此必须在其他地方运行。

If you are running your docker commands on your azure vm, you should be going to http:<azure vm ip>:9200 . 如果要在azure vm上运行docker命令,则应转到http:<azure vm ip>:9200 If you are running them on your machine, targeting a docker engine installed on your laptop using Docker machine or boot2docker, it should be http:<local vm ip>:9200 . 如果您在计算机上运行它们,并以使用Docker机器或boot2docker的便携式计算机上安装的Docker引擎为目标,则该引擎应为http:<local vm ip>:9200

If running locally, you can get the ip of that machine using boot2docker ip or docker-machine ls 如果在本地运行,则可以使用boot2docker ipboot2docker ip docker-machine ls获取该机器的boot2docker ip

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM