title: How can I run script automatically after Docker container startup
body: <p>I'm using Search Guard plugin to secure an elasticsearch cluster composed of multiple nodes.
  Here is my Dockerfile:</p>
  
  <pre><code>#!/bin/sh
  FROM docker.elastic.co/elasticsearch/elasticsearch:5.6.3
  
  USER root
  
  # Install search guard
  RUN bin/elasticsearch-plugin install --batch com.floragunn:search-guard-5:5.6.3-16 \
      &amp;&amp; chmod +x \
          plugins/search-guard-5/tools/hash.sh \
          plugins/search-guard-5/tools/sgadmin.sh \
          bin/init_sg.sh \
      &amp;&amp; chown -R elasticsearch:elasticsearch /usr/share/elasticsearch
  
  USER elasticsearch
  </code></pre>
  
  <p>To initialize SearchGuard (create internal users and assign roles). I need to run the script <code>init_sg.sh</code> after the container startup. 
  Here is the problem: Unless elasticsearch is running, the script will not initialize any security index. </p>
  
  <p>The script's content is :</p>
  
  <pre><code>sleep 10
  plugins/search-guard-5/tools/sgadmin.sh -cd config/ -ts config/truststore.jks -ks config/kirk-keystore.jks -nhnv -icl
  </code></pre>
  
  <p>Now, I just run the script manually after the container startup but since I'm running it on Kubernetes.. Pods may get killed or fail and get recreated automatically for some reason. In this case, the plugin have to be initialized automatically after the container startup! </p>
  
  <p>So how to accomplish this? Any help or hint would be really appreciated.</p>