elasticsearch / Dockerfile
dvilasuero's picture
dvilasuero HF Staff
Update Dockerfile
d400cf0
FROM python:3.9-slim
# Exposing ports
EXPOSE 9200
RUN apt update
RUN apt -y install python3.9-dev gcc gnupg apache2-utils systemctl curl sudo vim
# Create new user for starting elasticsearch
#RUN useradd -ms /bin/bash user -p "$(openssl passwd -1 ubuntu)"
#RUN echo 'user ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
# Install Elasticsearch
RUN curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
RUN echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | tee -a /etc/apt/sources.list.d/elastic-8.x.list
RUN apt update
RUN apt -y install elasticsearch=8.5.3
# Disable security in elasticsearch configuration
RUN sed -i "s/xpack.security.enabled: true/xpack.security.enabled: false/g" /etc/elasticsearch/elasticsearch.yml
RUN sed -i "s/cluster.initial_master_nodes/#cluster.initial_master_nodes/g" /etc/elasticsearch/elasticsearch.yml
RUN sed -i '$ a\cluster.routing.allocation.disk.threshold_enabled: false' /etc/elasticsearch/elasticsearch.yml
# Create elasticsearch directory and change ownership
RUN mkdir -p /var/run/elasticsearch
RUN chown -R 1000:1000 /var/run/elasticsearch
# Start elasticsearch
RUN echo "Starting Elasticsearch"
RUN systemctl daemon-reload
RUN systemctl enable elasticsearch
CMD ["elasticsearch"]