<p>I'm trying to run a docker image once to execute a task using a popular <a href="https://hub.docker.com/r/minio/mc/" rel="nofollow noreferrer">S3 client minio</a> the environment I'm dealing with use Kubernetes.</p>
<p>I can get shell access to execute tasks like so:</p>
<pre><code>docker run -it minio/mc --restart=Never --rm /bin/sh
</code></pre>
<p>similarly, I'm able to run busybox image in my K8S cluster.</p>
<pre><code>kubectl run busybox -i --tty --image=busybox --restart=Never --rm -- sh
</code></pre>
<p>However, I'm unable to get that mc client to work the same way it does with the previous example.</p>
<pre><code>kubectl run minio -i --tty  --image=minio/mc --restart=Never --rm --  /bin/sh
</code></pre>
<p>My shell would just exit, any ideas on how to keep the shell open? or how to pass bash commands to it before it dies?</p>

Deano
<p>This issue arises when container(s) in a Pod run some process(es) that complete. When its containers exit, the Pod completes. It is more common to have container(s) in a Pod that run continuously.</p>
<p>A solution to this completing problem is thus to keep the container running:</p>
<ol>
<li>Run the container in a Pod:</li>
</ol>
<pre class="lang-sh prettyprint-override"><code>kubectl run minio \
--image=minio/mc \
--restart=Never \
--command \
--  /bin/sh -c 'while true; do sleep 5s; done'
</code></pre>
<blockquote>
<p><strong>NOTE</strong> the Pod is kept running by the <code>while</code> loop in the container</p>
</blockquote>
<blockquote>
<p><strong>NOTE</strong> the image's entrypoint is overridden by <code>--command</code> and <code>/bin/sh</code></p>
</blockquote>
<ol start="2">
<li>Exec into the container, e.g.:</li>
</ol>
<pre class="lang-sh prettyprint-override"><code>kubectl exec --stdin --tty minio -- mc --help
</code></pre>
