Dockerfile文件
FROM hub.c.163.com/library/centos
WORKDIR /
COPY entrypoint.sh entrypoint.sh
WORKDIR /opt
MAINTAINER caozhiguang
RUN yum install -y java vim net-tools
COPY elasticsearch-5.5.3.tar.gz elasticsearch-5.5.3.tar.gz
RUN tar zxvf elasticsearch-5.5.3.tar.gz && rm -rf elasticsearch-5.5.3.tar.gz && groupadd admin && useradd admin -g admin && chown -R admin:admin .
RUN echo "network.host: 0.0.0.0" >>elasticsearch-5.5.3/config/elasticsearch.yml
RUN echo "http.port: 9200" >>elasticsearch-5.5.3/config/elasticsearch.yml
RUN echo "cluster.name: my-application" >>elasticsearch-5.5.3/config/elasticsearch.yml
RUN echo "http.cors.enabled: true" >>elasticsearch-5.5.3/config/elasticsearch.yml
RUN echo "http.cors.allow-origin: \"*\"" >>elasticsearch-5.5.3/config/elasticsearch.yml
RUN su admin -c "mkdir -p /opt/elasticsearch-5.5.3/logs && touch /opt/elasticsearch-5.5.3/logs/my-application.log"
RUN echo "vm.max_map_count=655360" >>/etc/sysctl.conf
VOLUME ["/opt"]
EXPOSE 9200
EXPOSE 9300
USER root
ENTRYPOINT ["/bin/sh","/entrypoint.sh"]
HEALTHCHECK --interval=5s --timeout=3s CMD status=`netstat -an | grep -wi listen | grep 9200 | wc -l`;if [ $status eq 1 ]; then echo "0"; else echo "1"; fi
entrypoint.sh
su admin -c "sh /opt/elasticsearch-5.5.3/bin/elasticsearch -d"
tail -f /opt/elasticsearch-5.5.3/logs/my-application.log
ElasticSearch 5.5.3 启动命令
docker run -it -d --net host --restart always -v /etc/localtime:/etc/localtime:ro -v /etc/hosts:/etc/hosts:ro --name es 192.168.1.3/library/ybles:5.5.3
ElasticSearch head 插件启动
docker run -itd --name es-head -p 9100:9100 mobz/elasticsearch-head:5
原文地址:https://www.cnblogs.com/caozg007/p/9248902.html