ElasticSearch docker-compose.yml and systemd service generator

Just looking for a simple solution with a single ElasticSearch node? See our new post Simple Elasticsearch setup with docker-compose

New: Now with ElasticSearch 7.13.4

This generator allows you to generate a systemd service file for a docker-compose setup that is automatically restarted if it fails.

Service name
Working directory (the elasticsearch docker configuration will reside here)
Cluster name (your can choose this arbitrarily, ElasticSearch will ignore nodes with other cluster names)
Number of ElasticSearch nodes (1 recommended for development, 2+ recommended for production)
Enable Dejavu (Web UI for ElasticSearch – http://localhost:1358)
Systemd .service file
docker-compose.yml

How to install

    1. Download myservice.service and docker-compose.yml by clicking on the blue download button
    2. Copy myservice.service and docker-compose.yml to the server
    3. Configure the system map limit: run echo -e "\nvm.max_map_count=524288\n" | sudo tee -a /etc/sysctl.conf && sudo sysctl -w vm.max_map_count=524288
    4. Install docker and docker-compose if not already installed – see this TechOverflow post for instructions!
    5. Run this from the directory where myservice.service and docker-compose.yml are placed:
Fill in the fields above to see this command!

Note that since the elasticsearch docker image usually needs to be downloaded, the first startup will take up to a couple of minutes.

Now you can run

wget -qO- http://127.0.0.1:9200/_cat/health

to check the status of the elasticsearch cluster. Example output with one elasticsearch instance:

1552711183 04:39:43 docker-cluster green 1 1 0 0 0 0 0 0 - 100.0%

To view the latest logs, use sudo journalctl -xfu myservice.service

To view the current service status, use sudo systemctl status myservice.service

The ElasticSearch data is stored in your directory by default, e.g. /opt/elasticsearch/esdata1.

If you have enabled Dejavu above, you can now go to the web UI: http://localhost:1358 and access the ElasticSearch server one you have created an index.

Data protection notice: All the data used for generating the service is processed entirely client-side in the browser. The data is not even sent to our server, therefore providing complete privacy for your entries!