DEV Community

Cover image for Dockerfile for Elasticsearch
VISHAK
VISHAK

Posted on • Edited on

3 3

Dockerfile for Elasticsearch

Elasticsearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured.

Elasticsearch is the central component of the Elastic Stack, a set of free and open tools for data ingestion, enrichment, storage, analysis, and visualization.

It is considerably easier and faster to run elasticsearch in a container than to install it on a host server.

1)Create a docker file and add the below contents.

# vim Dockerfile

FROM centos:7
MAINTAINER vishakkv954@gmail.com
RUN useradd -ms /bin/bash elasticsearch
RUN yum -y install java-1.8.0-openjdk-devel
RUN yum -y install wget
RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.rpm
RUN rpm -ivh elasticsearch-5.5.0.rpm
RUN mkdir /usr/share/elasticsearch/config
RUN cp -R /usr/share/elasticsearch/* /home/elasticsearch/
COPY elasticsearch.yml /home/elasticsearch/config/
COPY log4j2.properties /home/elasticsearch/config/
RUN chown -R elasticsearch:elasticsearch /home/elasticsearch/*
WORKDIR /home/elasticsearch
USER elasticsearch
EXPOSE 9200
EXPOSE 9300
CMD ["/home/elasticsearch/bin/elasticsearch"]
Enter fullscreen mode Exit fullscreen mode

elasticsearch.yml and log4j2.properties are the updated files with the configurations needed for our elasticsearch.Place both files in the same directory where dockerfile exists.

2) Build docker image
NB: be in the directory where dockerfile exists
docker build -t elasticsearh .
"elasticsearch is the image name"

3) Create docker container
# docker images #to get the docker image id
# docker run -d -P 9200:9200 -P 9300:9300 --name elastic <image id>

4) check container status
# docker ps

Play with docker🥂

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay