![](/img/trans.png)
[英]How to set port number for Elasticsearch running in Docker in host network mode
[英]network.host setting for Docker running ElasticSearch
我正在使用以下命令在我的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"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.