Skip to main content

Command Palette

Search for a command to run...

Elasticsearch on Docker

Updated
2 min readView as Markdown

1. Quick elasticsearch Docker container

Running Elasticsearch from the command line using docker run

Elasticsearch can be quickly started for development or testing use with the following command:

docker run --name elasticsearch -p 9200:9200 -it -m 1GB docker.elastic.co/elasticsearch/elasticsearch:8.13.4

Check the cluster health

curl http://127.0.0.1:9200/_cat/health

2. Running Elasticsearch using Docker Compose

We need to set vm.max_map_count kernel setting needs to be set to at least 262144 for production use. Depending on your platform.

Linux

check with the vm.max_map_count setting in /etc/sysctl.conf: Apply new count as elasticsearch expectes

sysctl -w vm.max_map_count=262144

OSX with Docker for Mac

The vm.max_map_count setting must be set within the xhyve virtual machine:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

Log in with root and no password. Then configure the sysctl setting as you would for Linux:

sysctl -w vm.max_map_count=262144

OSX with Docker Toolbox

The vm.max_map_count setting must be set via docker-machine:

docker-machine ssh

sudo sysctl -w vm.max_map_count=262144

Option #1: Elasticsearch docker-compose simple configuration

Run with the following command

docker-compose -f elasticsearch-simple-compose.yaml up -d

Check the cluster health

curl http://127.0.0.1:9200/_cat/health

Option #2 Elasticsearch docker-compose simple configuration with volume

Run with the following command

docker-compose -f elasticsearch-simple-compose-volume.yaml up -d

Check the cluster health

curl http://127.0.0.1:9200/_cat/health

Option #3 Elasticsearch docker-compose with CORS activated and XPack disabled

Run with the following command

docker-compose -f elasticsearch-cors-and-xpack-disabled-activated.yaml up -d

Check the cluster health

curl http://127.0.0.1:9200/_cat/health

To check the logs of the container

docker ps -a

docker logs elasticsearch

For more hacks on docker basic commands check with the following story

Hacks for Docker
*Am I using the docker the right way in my dev machine? Any hidden things happening with my docker? Do you have this in…*medium.com

Reference

Elasticsearch 5.x - Bootstrap checks failing
*I'm trying to use the Flink 5.x Elasticsearch sink connector to insert data to ES 5.2.1 instance hosted on a tiny VM…*stackoverflow.com

Install Elasticsearch with Docker | Elasticsearch Reference [6.6] | Elastic
*Elasticsearch is also available as Docker images. The images use centos:7 as the base image. A list of all published…*www.elastic.co

More from this blog

jinnabaalu

47 posts

Jinna Baalu | Infrastructure Automation