Installing ELK Stack in Docker

Having Troubling Implementing Docker? Here is the most straightforward guide!

Shelvi Garg
Analytics Vidhya
Published in
3 min readApr 26, 2021

--

Authors: Rishabh Gupta, Shelvi Garg

This is the most to-the-point tutorial on how to install the ELK — Elasticsearch stack through Docker. If you follow the step-by-step guide you will face no trouble in following the suit.

Before moving ahead, I assume you have downloaded the Docker Desktop. If you haven't here the link: https://www.docker.com/products/docker-desktop

Image Source: Medium

Step 1: Create a Directory /Folder with the name of ELK.

Step 2: Open the ELK Directory in your IDE (VS Code in my case).

Step 3: Create a File named docker-compose.yml in this directory.

Step 4: Copy-Paste the following commands : (it mentions some stuff about the dependencies we want to install, including Elastic Search and Kibana)

version: "3.7"services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
container_name: elasticsearch
restart: always
environment:
- xpack.security.enabled=false
- discovery.type=single-node
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
cap_add:
- IPC_LOCK
volumes:
- elasticsearch-data-volume:/usr/share/elasticsearch/data
ports:
- "9200:9200"
kibana:
container_name: kibana
image: docker.elastic.co/kibana/kibana:7.12.0
restart: always
environment:
SERVER_NAME: kibana
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
ports:
- "5601:5601"
depends_on:
- elasticsearch
volumes:
elasticsearch-data-volume:
driver: local

Step 5: Save the File and run the following command under the same directory terminal.

docker-compose -f docker-compose.yml up -d

You will see the system downloading your ELK Stack.

Step 6: Once the download is completed, you can go either to the Docker Desktop and look up 2 new Docker containers created there(as seen in image) or you can type on your terminal :

docker container ls
Docker Desktop Container: Image by Author

Step 7: You can run both the Elasticseacrh and Kibana Container, if it's not already been running from the Docker Desktop, run the button provided in front of the containers’ name.

You can run and stop it for further use too

Step 8: Last step is to finally see the end results.

Go to http://localhost:5601/ (localhost server we provided for Kibana) and http://localhost:9200/( Elasticsearch host server) to check if its working fine.

You will get something like this on 9200:

Image by Author

And something like this with 5601:

Image by Author

If you are getting Both the screens, congratulations, you have successfully crossed your biggest hurdle in learning elk stack!

…. and if you like this blog, please feel free to leave a few hearty claps! :)

--

--