Docker App Tutorial – Creating a docker container for ELK (Elasticsearch + Logstash + Kibana)

This is very quick tutorial for beginners to get up to speed with docker.

Docker Installation in OSX:
1. Download boot2docker package from https://github.com/boot2docker/osx-installer/releases
2. Run the package after download to install to applications.
3. Launch boot2docker from Apps, it will open in a terminal with a bash interface.
4. Run: “docker version” to test docker installation.

Getting a base docker image
To get a base Ubuntu image, run: docker pull ubuntu:14.04
Test the ubuntu image by: docker run ubuntu:14.04 echo “hello world”. You could also skip step 1 as if ubuntu:14.04 was not present it will be pulled when trying to run.
Get a terminal to the ubuntu server within docker: docker run -t -i ubuntu:14.04 /bin/bash

Creating custom docker image with ELK
1. Create a new docker file.
bash-3.2$ pwd
/Users/admin/work/docker/elk
bash-3.2$ touch Dockerfile

2. Add contents from link to the docker file. The comments should make the file self explanatory.
https://github.com/cyberabis/docker-elkauto/blob/master/Dockerfile

3. Create an image with the docker file
bash-3.2$ docker build -t=”username/elk” .

4. Start elastic search.
bash-3.2$ docker run -d -p 80:80 -p 3333:3333 -p 9200:9200 username/elk /elk_start.sh

5. If running in mac, get the IP of the VM. If Linux this will be the same IP as host.
bash-3.2$ boot2docker ip
The VM’s Host only interface IP address is: 192.168.59.103

6. Launch Kibana from http://192.168.59.103:80

7. Send some test messages to logstash.
echo ‘A test message1’ | nc 192.168.59.103 3333
echo ‘A test message2’ | nc 192.168.59.103 3333
echo ‘A test message3’ | nc 192.168.59.103 3333
echo ‘A test message4’ | nc 192.168.59.103 3333

8. Goto the sample dashboard in Kibana and you should see these messages.

Trying out this container from my docker hub repository
Use “sudo” before commands if required.
Make sure docker is installed.
Run: docker pull cyberabis/docker-elkauto
Run: docker run -d -p 80:80 -p 3333:3333 -p 9200:9200 cyberabis/docker-elkauto /elk_start.sh
Launch Kibana at port 80 of your docker!

Advertisements

One thought on “Docker App Tutorial – Creating a docker container for ELK (Elasticsearch + Logstash + Kibana)

  1. Pingback: Why Docker is awesome for a lean Tech Startup | Data Psyche

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s