<p>I have the following dockerfile:</p>

<pre><code>FROM node:8 as build
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
ENV PATH /usr/src/app/node_modules/.bin:$PATH
COPY package.json /usr/src/app/package.json
RUN npm install
COPY . /usr/src/app
</code></pre>

<p>publish to our artifactory. However, as there is no command / entrypoint provided, the docker would simply end immediately. so I usually use <code>docker run -d -t</code> to run it. However, when deploying it in kubernetes, I cannot specify the <code>args</code> -d and -t since I will get an error that node does not know the arguments -d and -t.</p>

<p>When adding the following entrypoint,</p>

<pre><code>ENTRYPOINT [ "tail", "-f", "/dev/null"]
</code></pre>

<p>The machine keeps crashing</p>

<p>How can I keep the pod running in background?</p>

user66875
<p>Make use of <code>-i</code> and <code>--tty</code> option of <code>kubectl run</code> command.</p>

<pre><code>kubectl run -i --tty --image=&lt;image&gt; &lt;name&gt; --port=80 --env="DOMAIN=cluster"
</code></pre>

<p>More info <a href="https://kubernetes.io/docs/reference/kubectl/docker-cli-to-kubectl/#docker-run" rel="nofollow noreferrer">here</a>.</p>

<p><strong>Update:</strong></p>

<p>In case of yaml files make use of <code>stdin</code> and <code>tty</code> option.</p>

<pre><code>apiVersion: v1 
kind: Pod 
metadata: 
  name: testpod
spec: 
  containers: 
    - name: testpod
      image: testimage
      stdin: true
      tty: true
</code></pre>

<p>More info <a href="https://stackoverflow.com/questions/37559704/kubectl-yaml-config-file-equivalent-of-kubectl-run-i-tty">here</a>.</p>
