<p>I have this docker image which has many useful tools installed. I use it inside docker to debug stuff, like testing connections to other containers. Now I would like to use this image in Kubernetes. However, because it doesn't run a process the pod will not start</p>

<p>Dockerfile:</p>

<pre><code>FROM ubuntu:latest
RUN .... useful tools ...
</code></pre>

<p>And the kubernetes file:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: uitls
spec:
  replicas: 1
  selector:
    matchLabels:
      bar: utils-xxl
  template:
    metadata:
      labels:
        bar: utils-xxl
    spec:
      containers:
      - name: utils
        image: jeanluca/base
</code></pre>

<p>When I try to apply this the pod it ends up in the <code>CrashLoopBackOff</code> state. Is there a way in kubernetes to start this pod? Maybe with <code>exec</code> and <code>bash</code>? Any suggestions?</p>

Jeanluca Scaljeri
<p>You can <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#run" rel="nofollow noreferrer"><code>kubectl run</code></a> a one-off pod for interactive debugging.</p>

<pre><code>kubectl run jeanluca-debug \
  --generator=run-pod/v1 \
  --rm -it \
  --image=jeanluca/base
</code></pre>

<p>This is basically equivalent to a <code>docker run</code> command with the same options, except that the pod name is a required positional parameter.</p>

<p>This technique is useful for the sorts of debugging tasks you describe.  If your image has tools like <code>redis-cli</code>, a <code>mysql</code> or <code>psql</code> client, DNS lookup tools like <code>host</code> or <code>dig</code>, and so on, it can be useful to figure out why exactly your combined system is broken.  The image's default command can be <code>CMD ["/bin/bash"]</code> and that's fine, but it will exit immediately if it doesn't have an input stream attached, so you need to run it via <code>kubectl run</code> like this instead of trying to get a Deployment to keep it alive.</p>

<p>In general there's no point to keeping a container or pod running that's doing literally nothing.  There are certainly tricks to keep a Docker container from exiting but I'd suggest avoiding them.</p>
