我正在尝试使用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/