<p>The log is created in the path <code>/var/lib/docker/containers/~/*</code>, and linked in the path <code>/var/log/container/*</code>.</p>

<p>I wonder how the log of each POD occurs in the <code>/var/lib/docker/containers/~/*</code> path.
Also, I am wondering if it is right to use the json-file driver in an environment that collects logs with fluentD.</p>

<p><a href="https://docs.docker.com/config/containers/logging/json-file/" rel="nofollow noreferrer"><code>json-file</code></a> is a logging driver supplied with Docker (usually the default Docker daemon setup)</p>

<p>For any container (CID) Docker will create a file in <code>/var/lib/docker/containers/CID/CID.log</code> for stdout and stderr. You can see this when you <code>docker run something</code>. </p>

<p>This logging is completely independent of Kubernetes. </p>

<h3>Kubernetes</h3>

<p>Kubernetes manages the symlinks in <code>/var/log/container/*</code> when Pod containers start or stop to point to the logfile of the underlying container runtime. </p>

<p>When using Docker, Kubernetes relies on the specific <code>json-file</code> Docker log path setup to create functional symlinks. If you use other <a href="https://docs.docker.com/config/containers/logging/configure/" rel="nofollow noreferrer">custom logging</a> solutions in Docker those Kubernetes symlinks won't be functional. </p>

<p>The recommended setup in the <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/" rel="nofollow noreferrer">kubernetes logging architecture</a> is to have Docker rotate log file at 10MB.</p>

<p><a href="https://github.com/kubernetes/kubernetes/blob/master/cluster/kube-up.sh" rel="nofollow noreferrer"><code>kube-up.sh</code></a>s GCE config is the defacto recommended setup for container run time configuration. <a href="https://github.com/kubernetes/kubernetes/blob/a8d71390cfd2d559beeccd8a2d8c3f5efec13a85/cluster/gce/gci/configure-helper.sh#L1312-L1315" rel="nofollow noreferrer"><code>json-file</code> is used and rotated at 10MB</a> and 5 old files are kept.</p>

<h3>CRI-O</h3>

<p>The alternate container runtime to Docker is cri-o. </p>

<p>cri-o also logs to a local json file, in a similar format to Docker. 
<code>kubelet</code> will rotate cri-o log files in a similar manner to Docker. </p>

<h3>Log Collection</h3>

<p>Any kubernetes log collectors will rely on the Kubernetes symlinks to json files. There should be an expectation that those files will be rotated underneath the collection. fluentd also supports this. </p>

<p>If your having an issue with your fluentd setup, I would recommend adding the specific detail of the issue you are seeing, with examples of the data you see in the log files and the data being received on the log collection end to your <a href="https://stackoverflow.com/questions/57554767/docker-log-driver-json-file-log-loss-when-rolling-update">other question</a> or the same detail as an issue against the fluentd project you used to setup your k8s log collection.</p>
