title: How to exec into a container and view file if container is in CrashLoopBackOff state
body: <p>I am running <code>nodejs</code> based application on <code>kubernetes</code> and it's in <code>CrashLoopBackOff</code> state.</p>
  
  <pre><code>kubectl logs api-5db677ff5-p824m
  
  &gt; api@0.0.1 staging /home/node
  &gt; NODE_ENV=staging node src/loader.js
  
  npm ERR! code ELIFECYCLE
  npm ERR! errno 1
  npm ERR! api@0.0.1 staging: `NODE_ENV=staging node src/loader.js`
  npm ERR! Exit status 1
  npm ERR!
  npm ERR! Failed at the api@0.0.1 staging script.
  npm ERR! This is probably not a problem with npm. There is likely additional 
  logging output above.
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/node/.npm/_logs/2019-04-04T14_24_26_908Z-debug.log
  </code></pre>
  
  <p>There is not much information in logs and I cannot access the complete log file from the given path in container.</p>
  
  <p>When I try check that file in container:</p>
  
  <pre><code>kubectl exec -it api-5db677ff5-p824m -- /bin/bash
  </code></pre>
  
  <p>It's giving me this error:</p>
  
  <blockquote>
    <p>error: unable to upgrade connection: container not found ("api")</p>
  </blockquote>