无法从Docker容器访问elasticsearch

时间:2018-09-04 11:32:14

标签: docker docker-compose devops devops-services

弹性搜索已在Docker容器上成功运行。但我无法在浏览器中访问。我正确映射端口。但是问题出在Docker容器中。容器中的elasticsearch使用localhost映射

127.0.0.1:9200
Dokcerfile
来自ubuntu:16.04 维护者Rajesh Gurram

运行apt-get更新&& \         apt-get install -y net-tools curl wget gnupg 运行apt-get install -y software-properties-common

运行add-apt-repository ppa:webupd8team / java && \         apt-get更新&& \         echo oracle-java7-installer shared / accepted-oracle-license-v1-1选择true | / usr / bin / debconf-set-selections && \         apt-get install -y oracle-java8-installer && apt-get clean

ENV JAVA_HOME / usr / lib / jvm / java-8-oracle

运行apt-get install apt-transport-https 运行wget -qO-https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt键添加-&& \         回声“ deb https://artifacts.elastic.co/packages/6.x/apt稳定的主要” | tee -a /etc/apt/sources.list.d/elastic-6.x.list && \         apt更新&& apt安装-y elasticsearch

RUN sed -i's /#network.host:192.168.0.1/network.host:0.0.0.0/g'/etc/elasticsearch/elasticsearch.yml

EXPOSE 9200 9300

2 个答案:

答案 0 :(得分:0)

在主机上运行以下命令将解决问题
$ sysctl -w vm.max_map_count = 262144

答案 1 :(得分:-1)

如果您想使用docker获取Elasticsearch的实例,则可以阅读以下指南:
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

如果ubuntu不是必需的基本映像,也可以直接从Elastic使用docker映像:
https://www.docker.elastic.co/

如果以后要升级到ELK堆栈,建议使用docker卷以实现持久性。