【问题标题】:Docker Container Exits Immediately Upon StartDocker 容器在启动时立即退出
【发布时间】:2018-05-12 09:32:16
【问题描述】:

我正在尝试在 Amazon Linux AMI(标准)上运行新的 Elasticsearch 6.0 docker 容器。我之前在另一个实例上运行 5.6 没有任何问题,但是当我启动它时我的容器立即崩溃。

这是我正在使用的命令:docker run -it -p 9200:9200 -p 9300:9300 -d docker.elastic.co/elasticsearch/elasticsearch:6.0.0

我参考了这篇关于 Docker 崩溃的帖子,但似乎仍然遇到了同样的问题:Why docker container exits immediately

我运行了 docker logs 并得到以下响应:

[2017-11-28T19:00:30,946][INFO ][o.e.n.Node               ] [] initializing ...
[2017-11-28T19:00:31,013][INFO ][o.e.e.NodeEnvironment    ] [eEXrI6m] using [1] data paths, mounts [[/ (overlay)]], net usable_space [4.5gb], net total_space [7.7gb], types [overlay]
[2017-11-28T19:00:31,014][INFO ][o.e.e.NodeEnvironment    ] [eEXrI6m] heap size [989.8mb], compressed ordinary object pointers [true]
[2017-11-28T19:00:31,015][INFO ][o.e.n.Node               ] node name [eEXrI6m] derived from node ID [eEXrI6mGTci22tpTNMMh8w]; set [node.name] to override
[2017-11-28T19:00:31,015][INFO ][o.e.n.Node               ] version[6.0.0], pid[1], build[8f0685b/2017-11-10T18:41:22.859Z], OS[Linux/4.9.62-21.56.amzn1.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_151/25.151-b12]
[2017-11-28T19:00:31,015][INFO ][o.e.n.Node               ] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.cgroups.hierarchy.override=/, -Des.path.home=/usr/share/elasticsearch, -Des.path.conf=/usr/share/elasticsearch/config]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [aggs-matrix-stats]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [analysis-common]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [ingest-common]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [lang-expression]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [lang-mustache]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [lang-painless]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [parent-join]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [percolator]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [reindex]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [repository-url]
[2017-11-28T19:00:32,283][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [transport-netty4]
[2017-11-28T19:00:32,284][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded module [tribe]
[2017-11-28T19:00:32,284][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded plugin [ingest-geoip]
[2017-11-28T19:00:32,284][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded plugin [ingest-user-agent]
[2017-11-28T19:00:32,284][INFO ][o.e.p.PluginsService     ] [eEXrI6m] loaded plugin [x-pack]
[2017-11-28T19:00:34,795][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/120] [Main.cc@128] controller (64 bit): Version 6.0.0 (Build 8e6ab35cf803a2) Copyright (c) 2017 Elasticsearch BV
[2017-11-28T19:00:34,834][INFO ][o.e.d.DiscoveryModule    ] [eEXrI6m] using discovery type [zen]
[2017-11-28T19:00:35,513][INFO ][o.e.n.Node               ] initialized
[2017-11-28T19:00:35,513][INFO ][o.e.n.Node               ] [eEXrI6m] starting ...
[2017-11-28T19:00:35,648][INFO ][o.e.t.TransportService   ] [eEXrI6m] publish_address {xxx.xx.x.x:9300}, bound_addresses {0.0.0.0:9300}
[2017-11-28T19:00:35,664][INFO ][o.e.b.BootstrapChecks    ] [eEXrI6m] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2017-11-28T19:00:35,675][INFO ][o.e.n.Node               ] [eEXrI6m] stopping ...
[2017-11-28T19:00:35,734][INFO ][o.e.n.Node               ] [eEXrI6m] stopped
[2017-11-28T19:00:35,734][INFO ][o.e.n.Node               ] [eEXrI6m] closing ...
[2017-11-28T19:00:35,745][INFO ][o.e.n.Node               ] [eEXrI6m] closed

【问题讨论】:

    标签: amazon-web-services docker elasticsearch amazon-ec2


    【解决方案1】:

    您的错误似乎在这里:

    错误:[2] 引导检查失败 1: elasticsearch 进程的最大文件描述符 [4096] 太低,增加到至少 [65536] [2]: max virtual memory area vm.max_map_count [65530] 太低,至少增加到[262144]

    ElasticSearch 对需要足够的文件描述符和主机提供的内存很挑剔;他们页面上的文档包含一些有关如何设置的信息 - 取决于您的主机是什么:

    https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

    根据上述调整您的主机后,他们的页面在那里讨论了docker-compose 的设置,但是如果您仍想使用docker run,您可以找到等效的命令here

    【讨论】:

      【解决方案2】:

      您可以尝试添加 ulimit 部分:

      services:
        elastic:
            image: elasticsearch
            ulimits:
                nofile:
                    soft: 65536
                    hard: 65536
      

      或更改限制

      /etc/security/limits.conf
      

      你可以看到实际的限制

      cat /proc/<pid>/limits
      

      进程运行时。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-03-28
        • 1970-01-01
        • 2017-03-12
        • 1970-01-01
        相关资源
        最近更新 更多