How to install Elasticsearch plugins with docker container?

Solution 1:

If you are using Dockerfile try something link below

FROM elasticsearch:2
RUN /usr/share/elasticsearch/bin/plugin install --batch <plugin>

After that you can build

$ docker build -t elasticsearch-aws .

Here is good reference https://www.elastic.co/blog/elasticsearch-docker-plugin-management .

If you want to install plugin directly from docker follow below steps.

  1. Login to docker docker exec -it <id> /bin/bash
  2. Find elasticsearch home dir and execute your command to install plugin.

But remember this way it is not persistent.

Solution 2:

If you are using elasticsearch 6, the commands to install plugins are a bit different than in @asktyagi's answer. Put this in your Dockerfile

FROM elasticsearch:6.8.3
RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-icu && \ 
    /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-phonetic

Then

docker build -t elasticsearch .