I'm using this docker repository to install elasticsearch
and searchguard
The searchguard requires running a script bin/init_sg.sh
after the elasticsearch is fully loaded.
I don't like running docker exec -it elasticsearch bin/init_sg.sh
manually everytime the container is recreated. I'm looking for a way of doing it programmatically in the Dockerfile
or docker-compose.yml
.
My main problem right now is finding the primary process pid in the dockerfile and making sure the elasticsearch service is fully loaded. Can anyone give me suggestions on how to do that?
Unsuccessful Dockerfile
FROM docker.elastic.co/elasticsearch/elasticsearch:5.6.3
COPY config/ config/
COPY bin/ bin/
# Search Guard plugin
# https://github.com/floragunncom/search-guard/wiki
RUN elasticsearch-plugin install --batch com.floragunn:search-guard-5:5.6.3-16 \
&& chmod +x \
plugins/search-guard-5/tools/hash.sh \
plugins/search-guard-5/tools/sgadmin.sh
# Add your elasticsearch plugins setup here
# Example: RUN elasticsearch-plugin install analysis-icu
CMD bin/elasticsearch && while [ -d /proc/1 ] ; do sleep 1; done && bin/init_sg.sh