<p>I need to be able to run a shell script (my script is for initializing my db cluster) to initialize my pods in Kubernetes,</p>

<p>I don't want to create my script inside my dockerfile because I get my image directly from the web so I don't want to touch it.</p>

<p>So I want to know if there is a way to get my script in to one of my volumes so I can execute it like that:</p>

<pre><code>spec:
  containers:
  - name: command-demo-container
    image: debian
    command: ["./init.sh"]
  restartPolicy: OnFailure
</code></pre>

<p>It depends what exactly does your init script do. But the <a href="https://kubernetes.io/docs/concepts/workloads/pods/init-containers/" rel="nofollow noreferrer">InitContainers</a> should be helpful in such cases. Init containers are run before the main application container is started and can do some preparation work such as create configuration files etc. </p>

<p>You would still need your own Docker image, but it doesn't have to be the same image as the database one.</p>
