amazon-web-services - 无法在Amazon Ec2实例上的docker中运行Elasticsearch

标签 amazon-web-services docker elasticsearch startup-error

我正在尝试使用t2.medium实例在docker容器中运行elasticsearch 7.7,并经历了this SO问题和official ES docs on installing ES using docker,但即使在给discovery.type: single-node后也没有绕过几篇文章中提到的引导检查。

我的elasticsearch.yml文件

cluster.name: scanner
node.name: node-1
network.host: 0.0.0.0
discovery.type: single-node
cluster.initial_master_nodes: node-1 // tried explicitly giving this but no luck
xpack.security.enabled: true 

我的Dockerfile
FROM docker.elastic.co/elasticsearch/elasticsearch:7.7.0
COPY elasticsearch.yml /usr/share/elasticsearch/elasticsearch.yml
USER root
RUN chmod go-w /usr/share/elasticsearch/elasticsearch.yml
RUN chown root:elasticsearch /usr/share/elasticsearch/elasticsearch.yml
USER elasticsearch

这就是我构建和运行图像的方式。
docker build -t es:latest .
docker run --ulimit nofile=65535:65535 -p 9200:9200 es:latest

和相关的错误日志

75", "message": "bound or publishing to a non-loopback address, enforcing bootstrap checks" } ERROR: 1 bootstrap checks failed 1: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured ERROR: Elasticsearch did not exit normally - check the logs at /usr/share/elasticsearch/logs/docker-cluster.log

最佳答案

问题出在您的Dockerfile上,您正在将自己的elasticsearch.yml复制到/usr/share/elasticsearch位置,而如果您从同一链接中看到customized docker image section,您已经在问题中提到过。

它将文件复制到路径中/usr/share/elasticsearch/config位置notet文件夹中,因为这是Elasticsearch用来读取配置文件的路径。

从同一链接,这就是您应该如何在Dockerfile中复制和更改文件的权限。

COPY --chown = elasticsearch:elasticsearch elasticsearch.yml / usr / share / elasticsearch / config /

之后,您还可以通过使用docker exec -it <your container id>进入容器,检查要复制的文件内容是否正确。

关于amazon-web-services - 无法在Amazon Ec2实例上的docker中运行Elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62080468/

相关文章:

docker - 调用ListTables操作时发生错误(426): Upgrade Required

azure - 在 Azure 容器中运行 docker 命令

python - 如何更改 Elasticsearch 8 中不推荐使用 'body' 参数的语法?

amazon-web-services - AWS Fn::ImportValue !Sub 不接受值

python - 连接RDS上的MySQL数据库

amazon-web-services - 如何在Docker AWS日志驱动程序的docker run命令中将file_fingerprint_lines选项添加为--log-opt选项

amazon-web-services - 将 S3 静态 Web 托管内容设为私有(private)

docker - 在 docker 容器中使用 apache 服务器配置 SSL

elasticsearch - 是否可以使用update_by_query API更新到Elasticsearch中具有字段数组的文档?

elasticsearch - BULK API : Malformed action/metadata line [3], 需要 START_OBJECT 但找到 [VALUE_STRING]