This image is a small wrapper around the official Elasticsearch Docker image to allow for arbitrary hooks to be ran before or after Elasticsearch starts or stops.
Since this image is a wrapper, the documentation for running Elasticsearch in Docker also applies for this image. Running this image without any hooks is identical to just running the base image.
$ docker run -e prestart_hook='
bin/elasticsearch-plugin install analysis-icu
' quay.io/qoqodev/elasticsearch-hooks
$ docker run -e poststart_hook='
until nc -z localhost 9300; do
echo "Not up yet"
sleep 1
done
echo "Ready to go!"
' quay.io/qoqodev/elasticsearch-hooks
$ docker run -e prestop_hook='
while curl http://localhost:9200/_cat/shards | grep -E "RELOCATING.+$(hostname) ->"; do
echo "Still relocating shards off of this node"
sleep 30
done
' quay.io/qoqodev/elasticsearch-hooks
$ docker run \
-e discovery.zen.ping.unicast.hosts=elasticsearch \
-e poststop_hook='
while curl http://elasticsearch:9200/_cat/master | grep "$(hostname)"; do
echo "This node is still considered the elected master"
echo "Waiting a bit for the next cluster state update"
sleep 5
done
' quay.io/qoqodev/elasticsearch-hooks
Don't like environment variables? Mount the hooks onto the /hooks
directory in the container and they'll be run appropriately:
$ ls
poststart poststop prestart prestop
$ docker run -v $(pwd):/hooks quay.io/qoqodev/elasticsearch-hooks