The log is created in the path /var/lib/docker/containers/~/*
, and linked in the path /var/log/container/*
.
I wonder how the log of each POD occurs in the /var/lib/docker/containers/~/*
path. Also, I am wondering if it is right to use the json-file driver in an environment that collects logs with fluentD.
json-file
is a logging driver supplied with Docker (usually the default Docker daemon setup)
For any container (CID) Docker will create a file in /var/lib/docker/containers/CID/CID.log
for stdout and stderr. You can see this when you docker run something
.
This logging is completely independent of Kubernetes.
Kubernetes manages the symlinks in /var/log/container/*
when Pod containers start or stop to point to the logfile of the underlying container runtime.
When using Docker, Kubernetes relies on the specific json-file
Docker log path setup to create functional symlinks. If you use other custom logging solutions in Docker those Kubernetes symlinks won't be functional.
The recommended setup in the kubernetes logging architecture is to have Docker rotate log file at 10MB.
kube-up.sh
s GCE config is the defacto recommended setup for container run time configuration. json-file
is used and rotated at 10MB and 5 old files are kept.
The alternate container runtime to Docker is cri-o.
cri-o also logs to a local json file, in a similar format to Docker. kubelet
will rotate cri-o log files in a similar manner to Docker.
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.
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 other question or the same detail as an issue against the fluentd project you used to setup your k8s log collection.