Search code examples
elasticsearchdockerdocker-composeelasticsearch-plugin

How to install ElasticSeach plugins using docker compose


I have a docker-compose.yml file with an elastic search image:

elasticsearch:
  image: elasticsearch
  ports:
    - "9200:9200"
  container_name: custom_elasticsearch_1

If I want to install additional plugins like the HQ interface or the attachment-mapper I have to do a manual installation with the following commands:

$ docker exec custom_elasticsearch_1 plugin install royrusso/elasticsearch-HQ
$ docker exec custom_elasticsearch_1 plugin install mapper-attachments

Is there a way to install them automatically when I run the docker-compose up command?


Solution

  • 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_1
    
    RUN elasticsearch-plugin install royrusso/elasticsearch-HQ