<p>I am running a deployment which contains three containers the app, nginx and  cloud sql instance. I have a lot of print statements in my python based app.</p>

<p>Every time a user interacts with the app, outputs are printed. I want to know if these logs are saved by default at any location.</p>

<p>I am worried that these logs might consume the space on the nodes in the cluster running it. Does this happen ? or Kubernetes deployments by default don't save any logs by default?</p>

<p>The applications run in containers usually under Docker and the stdout/stderr logs are saved for the lifetime of the container in the graph directory (usually <code>/var/lib/docker</code>)</p>

<p>You can look at the logs with either:</p>

<pre><code>$ kubectl logs &lt;pod-name&gt; -c &lt;container-in-pod&gt;
</code></pre>

<p>Or:</p>

<pre><code>$ ssh &lt;node&gt;
$ docker logs &lt;container&gt;
</code></pre>

<p>If you'd like to know more where they are stored you can go into the <code>/var/lib/docker</code> directory and see the logs stored in JSON format:</p>

<pre><code>$ cd /var/lib/docker/containers
$ find . | grep json.log
./3454a0681100986248fd81856fadfe7cd95a1a6467eba32adb33da74c2c5443d/3454a0681100986248fd81856fadfe7cd95a1a6467eba32adb33da74c2c5443d-json.log
./80a87a9529a55f8d3fb9b814f0158dc91686704222e252b256455bcde48f56a5/80a87a9529a55f8d3fb9b814f0158dc91686704222e252b256455bcde48f56a5-json.log
...
</code></pre>

<p>If you'd like to do garbage collection on 'Exited' containers you can read more about it <a href="https://kubernetes.io/docs/concepts/cluster-administration/kubelet-garbage-collection/" rel="nofollow noreferrer">here</a>. </p>

<p>Another way is to set up a cron job that runs periodically on your nodes that does this:</p>

<pre><code>$ docker system prune -a --force
</code></pre>
