<p>I am trying to read the container logs through fluentd and pass it to the elastic search. I have mounted the directories from the host onto fluentd container which include all symlinks and actual files.
But when I see the fluentd container logs , it say those logs, present under <code>/var/log/pods/</code> are unreadable. Then I manually navigated to the path under fluentd container where logs are present but unfortunately I got permission denied issue.
I went till <code>/var/lib/docker/containers</code> , then the permissions were 0700 and owner was root. Even I am trying to run my fluentd container by setting<br>
<code>
- name: FLUENT_UID
  value: "0"
</code>
But still it is not able to read.</p>

<p><code>
volumes:
  - name: varlog
    hostPath:
      path: /var/log/
   - name: varlibdockercontainers
     hostPath:
      path: /var/lib/docker/containers</code></p>

<p>.....
<code>
volumeMounts:
   - name: varlog
     mountPath: /var/log/
   - name: varlibdockercontainers
     mountPath: /var/lib/docker/containers
</code></p>

Nish
<p>You should take a look at <a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" rel="nofollow noreferrer">security contexts</a>. Among other things they allow you to specify the user that will run in the container with <code>runAsUser</code>, the primary group of that user with <code>runAsGroup</code>, and the volume owner with <code>fsGroup</code>.</p>
