docker - 运行 ElasticSearch 的 Docker 的 network.host 设置

标签 docker elasticsearch ubuntu-16.04

我在我的 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

所以,我的问题是:

  1. 如何在 docker 上启动 elasticsearch 并发布端口 9200 和 9300 到主机?

  2. 是否需要 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/

相关文章:

elasticsearch - Elasticsearch :连接被拒绝

php - libsodium "Call to undefined function"错误

visual-studio-code - 如何在Visual Studio Code SERVER上运行/编译Pascal? (在Ubuntu上使用FPC吗?)

docker - Docker运行hello-world不起作用

java - Arquillian Cube 基本示例/教程 JMX 远程访问超时

ios - 如何使用 docker 构建 react native iOS 应用程序?

lucene - 与 ElasticSearch 的精确文档匹配

elasticsearch - OpenSearch docker 实例仅允许 HTTPS 连接

尽管外键中存在 ON UPDATE CASCADE,MySQL 仍不允许更新

docker - 撰写文件 './docker-compose.yaml'无效,原因是:服务不支持的配置: 'pihole'