title: Pod gets into status of CrashLoopBackOff and gets restarted repeatedly - Exit code is 0
body: <p>I have a docker container that is running fine when I run it using docker run. I am trying to put that container inside a pod but I am facing issues. The first run of the pod shows status as "Completed". And then the pod keeps restarting with CrashLoopBackoff status. The exit code however is 0. </p>
  
  <p>Here is the result of kubectl describe pod :</p>
  
  <pre><code>Name:           messagingclientuiui-6bf95598db-5znfh
  Namespace:      mgmt
  Node:           db1mgr0deploy01/172.16.32.68
  Start Time:     Fri, 03 Aug 2018 09:46:20 -0400
  Labels:         app=messagingclientuiui
              pod-template-hash=2695115486
  Annotations:    &lt;none&gt;
  Status:         Running
  IP:             10.244.0.7
  Controlled By:  ReplicaSet/messagingclientuiui-6bf95598db
  Containers:
    messagingclientuiui:
      Container ID:   docker://a41db3bcb584582e9eacf26b02c7ef26f57c2d43b813f44e4fd1ba63347d3fc3
  Image:          172.32.1.4/messagingclientuiui:667-I20180802-0202
  Image ID:       docker-pullable://172.32.1.4/messagingclientuiui@sha256:89a002448660e25492bed1956cfb8fff447569e80ac8b7f7e0fa4d44e8abee82
  Port:           9087/TCP
  Host Port:      0/TCP
  State:          Waiting
    Reason:       CrashLoopBackOff
  Last State:     Terminated
    Reason:       Completed
    Exit Code:    0
    Started:      Fri, 03 Aug 2018 09:50:06 -0400
    Finished:     Fri, 03 Aug 2018 09:50:16 -0400
  Ready:          False
  Restart Count:  5
  Environment Variables from:
    mesg-config  ConfigMap  Optional: false
  Environment:     &lt;none&gt;
  Mounts:
    /docker-mount from messuimount (rw)
    /var/run/secrets/kubernetes.io/serviceaccount from default-token-2pthw (ro)
  Conditions:
    Type           Status
    Initialized    True
    Ready          False
    PodScheduled   True
  Volumes:
    messuimount:
      Type:          HostPath (bare host directory volume)
      Path:          /mon/monitoring-messui/docker-mount
      HostPathType:
    default-token-2pthw:
      Type:        Secret (a volume populated by a Secret)
      SecretName:  default-token-2pthw
      Optional:    false
  QoS Class:       BestEffort
  Node-Selectors:  &lt;none&gt;
  Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                   node.kubernetes.io/unreachable:NoExecute for 300s
  Events:
    Type     Reason                 Age              From                            Message
    ----     ------                 ----             ----                      -------
    Normal   Scheduled              4m               default-scheduler         Successfully assigned messagingclientuiui-6bf95598db-5znfh to db1mgr0deploy01
    Normal   SuccessfulMountVolume  4m               kubelet, db1mgr0deploy01  MountVolume.SetUp succeeded for volume "messuimount"
    Normal   SuccessfulMountVolume  4m               kubelet, db1mgr0deploy01  MountVolume.SetUp succeeded for volume "default-token-2pthw"
    Normal   Pulled                 2m (x5 over 4m)  kubelet, db1mgr0deploy01  Container image "172.32.1.4/messagingclientuiui:667-I20180802-0202" already present on machine
    Normal   Created                2m (x5 over 4m)  kubelet, db1mgr0deploy01  Created container
    Normal   Started                2m (x5 over 4m)  kubelet, db1mgr0deploy01  Started container
    Warning  BackOff                1m (x8 over 4m)  kubelet, db1mgr0deploy01  Back-off restarting failed container
  </code></pre>
  
  <p>kubectl get pods</p>
  
  <pre><code>      NAME                              READY     STATUS             RESTARTS   AGE
  messagingclientuiui-6bf95598db-5znfh   0/1       CrashLoopBackOff   9          23m
  </code></pre>
  
  <p>I am assuming we need a loop to keep the container running in this case. But I dont understand why it worked when it ran using docker and not working when it is inside a pod.  Shouldnt it behave the same ?</p>
  
  <p>How do we henerally debug CrashLoopBackOff status apart from running kubectl describe pod and kubectl logs </p>