我在我的 ubuntu 主机上运行一个 docker,其内容如下:
docker run -d --rm -p 9200:9200 -p 9300:9300 --name elasticsearch6.6.1 docker.elastic.co/elasticsearch/elasticsearch:6.6.1
稍后当我这样查询时,我失败了:
curl 'http://localhost:9200/?pretty'
失败看起来是这样的:
curl ' http://localhost:9200/?pretty '
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/dcac22e9-6b6f-443b-8497-c093dd6bb804.sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (56) Recv failure: Connection reset by peer
所以,我的问题是:
如何在 docker 上启动 elasticsearch 并发布端口 9200 和 9300 到主机?
是否需要 network.host=_ site _ 设置?
谢谢,
最佳答案
查看您提到的图像后,请检查容器的日志,因为您可能会遇到类似这样的错误:
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
在我的案例中,解决方法是:sysctl -w vm.max_map_count=262144
然后当我尝试 curl
命令时,它按预期工作:
curl 'http://localhost:9200/?pretty'
{
"name" : "WgMEnP1",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "2USHCgsWTQOWK5g76uOnNQ",
"version" : {
"number" : "6.6.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "1fd8f69",
"build_date" : "2019-02-13T17:10:04.160291Z",
"build_snapshot" : false,
"lucene_version" : "7.6.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
关于docker - 运行 ElasticSearch 的 Docker 的 network.host 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55264080/