使用docker运行elasticsearch

时间:2015-10-31 04:56:42

标签: elasticsearch docker docker-machine elasticsearch-2.0

我是关于弹性搜索的新手,请原谅我,如果我的问题是愚蠢的。我试着用docker运行它。在我从docker hub中提取弹性搜索图像后,我使用命令运行它:

docker run -p 9200:9200 -p 9300:9300 --name=ES elasticsearch

但是当我打开http://192.168.99.100:9200(我的码头机器ip是192.168.99.100)时,该页面不可用。

我尝试更改我的elasticsearch.yml,如下所示:

network.publish_host: 192.168.99.100

但它不起作用。有人帮帮我吗?

感谢。

更新1

我尝试使用network.publish_host直接在命令行上传递--network.publish_host=192.168.99.100设置(如提到的@Val),但它仍无效。日志:

$ docker run -p 9200:9200 -p 9300:9300 --name=ES elasticsearch  --network.publish_host=192.168.99.100
[2015-10-31 05:18:57,305][INFO ][node                     ] [Slipstream] version[2.0.0], pid[1], build[de54438/2015-10-22T08:09:48Z]
[2015-10-31 05:18:57,306][INFO ][node                     ] [Slipstream] initializing ...
[2015-10-31 05:18:57,445][INFO ][plugins                  ] [Slipstream] loaded [], sites []
[2015-10-31 05:18:57,655][INFO ][env                      ] [Slipstream] using [1] data paths, mounts [[/usr/share/elasticsearch/data (/dev/sda1)]], net usable_space [11.5gb], net total_space [18.1gb], spins? [possibly], types [ext4]
[2015-10-31 05:19:01,778][INFO ][node                     ] [Slipstream] initialized
[2015-10-31 05:19:01,784][INFO ][node                     ] [Slipstream] starting ...
[2015-10-31 05:19:02,072][INFO ][transport                ] [Slipstream] publish_address {192.168.99.100:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2015-10-31 05:19:02,140][INFO ][discovery                ] [Slipstream] elasticsearch/D9frl4aqQlG_ihimJ6eY_w
[2015-10-31 05:19:05,309][INFO ][cluster.service          ] [Slipstream] new_master {Slipstream}{D9frl4aqQlG_ihimJ6eY_w}{192.168.99.100}{192.168.99.100:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2015-10-31 05:19:05,370][INFO ][http                     ] [Slipstream] publish_address {192.168.99.100:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2015-10-31 05:19:05,373][INFO ][node                     ] [Slipstream] started
[2015-10-31 05:19:05,496][INFO ][gateway                  ] [Slipstream] recovered [0] indices into cluster_state

1 个答案:

答案 0 :(得分:0)

由于OP使用的是Mac,因此port forwarded (with boot2docker or with docker machine)的端口9200需要为VM (VirtualBox) level

VBoxManage controlvm "boot2docker-vm" --natpf1 "tcp-port9200 ,tcp,,9200,,9200"
VBoxManage controlvm "boot2docker-vm" --natpf1 "udp-port9200 ,udp,,9200,,$9200

controlvm如果虚拟机正在运行,则modifyvm是虚拟机已停止)