<p>I'm now trying to run a simple container with shell (/bin/bash) on a Kubernetes cluster.</p>

<p>I thought that there was a way to keep a container running on a Docker container by using <code>pseudo-tty</code> and detach option (<code>-td</code> option on <code>docker run</code> command).</p>

<p>For example,</p>

<pre><code>$ sudo docker run -td ubuntu:latest
</code></pre>

<p>Is there an option like this in Kubernetes?</p>

<p>I've tried running a container by using a <code>kubectl run-container</code> command like:</p>

<pre><code>kubectl run-container test_container ubuntu:latest --replicas=1
</code></pre>

<p>But the container exits for a few seconds (just like launching with the <code>docker run</code> command without options I mentioned above). And ReplicationController launches it again repeatedly.</p>

<p>Is there a way to keep a container running on Kubernetes like the <code>-td</code> options in the <code>docker run</code> command?</p>

<p>Containers are meant to run to completion.  You need to provide your container with a task that will never finish.  Something like this should work:</p>

<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Pod
metadata:
  name: ubuntu
spec:
  containers:
  - name: ubuntu
    image: ubuntu:latest
    # Just spin &amp; wait forever
    command: [ "/bin/bash", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]
</code></pre>
