Elasticsearch on Docker
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



