How to install ElasticSeach plugins using docker compose
Here is a blog post by Elastic pertaining to exactly that! You need to use a Dockerfile which executes commands to extend an image. Your Dockerfile will look something like this:
FROM custom_elasticsearch_1RUN plugin install royrusso/elasticsearch-HQ
Inspired by @NickPridorozhko's answer, but updated and tested with elasticsearch^7.0.0 (with docker stack / swarm), example with analysis-icu:
elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:7.3.0 user: elasticsearch command: > /bin/sh -c "./bin/elasticsearch-plugin list | grep -q analysis-icu || ./bin/elasticsearch-plugin install analysis-icu; /usr/local/bin/docker-entrypoint.sh" ...
The main difference are the updated commands for ^7.0.0, and the use of the docker entrypoint instead of ./bin/elasticsearch (in a stack's context, you'd get an error related to a limit of spawnable processes).
This works for me. Install plugin before and then continue with starting the elasticsearch.
elasticsearch: image: elasticsearch command: - sh - -c - "plugin list | grep -q plugin_name || plugin install plugin_name; /docker-entrypoint.sh elasticsearch"