<p><a href="https://www.fluentd.org/" rel="nofollow noreferrer">Fluentd</a> in Docker cannot tail from my log file</p>
<p>My input in <code>/var/log/logf/a.log</code>:</p>
<pre><code>test 1st log
test 2nd log
test 3rd log
</code></pre>
<p>and my config in <code>/opt/app/conf/fluent.conf</code>:</p>
<pre><code>&lt;source&gt;
   @type tail
   path /var/log/logf/a.log
   tag test
   read_from_head true
   &lt;parse&gt;
      @type none
      message_key test
   &lt;/parse&gt;
&lt;/source&gt;

&lt;match test&gt;
   @type stdout
&lt;/match&gt;
</code></pre>
<p>and my <code>Dockerfile</code> id <code>/opt/app/Dockerfile</code></p>
<pre><code>FROM fluent/fluentd:v1.11-debian-1
USER root

COPY ./conf/fluent.conf /fluentd/etc
RUN [&quot;gem&quot;, &quot;install&quot;, &quot;fluent-plugin-elasticsearch&quot;, &quot;--no-document&quot;, &quot;--version&quot;, &quot;3.5.2&quot;]
USER fluent
</code></pre>
<p>i run my <code>Dockerfile</code></p>
<pre><code>$ sudo docker build -t log-app .
$ sudo docker run -d --name logging log-app:latest
$ sudo docker logs -f logging
</code></pre>
<p>and I got result stuck, I don't know why</p>
<pre><code>2020-10-26 10:24:58 +0000 [info]: parsing config file is succeeded path=&quot;/fluentd/etc/fluent.conf&quot;
2020-10-26 10:24:58 +0000 [info]: gem 'fluent-plugin-elasticsearch' version '3.5.2'
2020-10-26 10:24:58 +0000 [info]: gem 'fluentd' version '1.11.4'
2020-10-26 10:24:58 +0000 [warn]: 'pos_file PATH' parameter is not set to a 'tail' source.
2020-10-26 10:24:58 +0000 [warn]: this parameter is highly recommended to save the position to resume tailing.
2020-10-26 10:24:58 +0000 [info]: using configuration file: &lt;ROOT&gt;
 &lt;source&gt;
   @type tail
   path &quot;/var/log/logf/a.log&quot;
   tag &quot;test&quot;
   read_from_head true
   &lt;parse&gt;
      @type &quot;none&quot;
      message_key &quot;test&quot;
      unmatched_lines
   &lt;/parse&gt;
 &lt;/source&gt;
 &lt;match test&gt;
    @type stdout
 &lt;/match&gt;
&lt;/ROOT&gt;
2020-10-26 10:24:58 +0000 [info]: starting fluentd-1.11.4 pid=6 ruby=&quot;2.6.6&quot;
2020-10-26 10:24:58 +0000 [info]: spawn command to main:  cmdline=[&quot;/usr/local/bin/ruby&quot;, &quot;-Eascii- 8bit:ascii-8bit&quot;, &quot;/usr/local/bundle/bin/fluentd&quot;, &quot;-c&quot;, &quot;/fluentd/etc/fluent.conf&quot;, &quot;-p&quot;, &quot;/fluentd/plugins&quot;, &quot;--under-supervisor&quot;]
2020-10-26 10:24:59 +0000 [info]: adding match pattern=&quot;test&quot; type=&quot;stdout&quot;
2020-10-26 10:24:59 +0000 [info]: adding source type=&quot;tail&quot;
2020-10-26 10:24:59 +0000 [warn]: #0 'pos_file PATH' parameter is not set to a 'tail' source.
2020-10-26 10:24:59 +0000 [warn]: #0 this parameter is highly recommended to save the position to resume tailing.
2020-10-26 10:24:59 +0000 [info]: #0 starting fluentd worker pid=15 ppid=6 worker=0
2020-10-26 10:24:59 +0000 [info]: #0 fluentd worker is now running worker=0
</code></pre>
<p>I think this is a permission problem, but I'm not sure because this <a href="https://www.fluentd.org/" rel="nofollow noreferrer">Fluentd</a> not throw an error, can you solve this problem guys?</p>
<hr />
<p><strong>[SOLVED]</strong> completely solved by mr karan shah's explanation</p>
<p>i was solved with docker-compose with mounting volume, below:</p>
<p>in file <code>/opt/app/docker-compose.yaml</code></p>
<pre><code>version: '2'

services:
  fluentd:
    build: .
    container_name: fl-logging
    volumes:
      - &quot;./conf/:/fluentd/etc:ro&quot;
      - &quot;/var/log/logf:/var/log/logf&quot;
</code></pre>
<p>and run the docker compose</p>
<pre><code> $ sudo docker-compose up -d --build
</code></pre>

Ganang Wahyu W
<p>The issue is that you have not mounted the local log files into the Fluentd container for it to be accessible.</p>
<p>Use a command like below.</p>
<p><code>sudo docker run -d --name logging -v PATHTOYOURLOGFILE:/var/log/logf/ log-app:latest</code></p>
<p>Read more about volumes <a href="https://docs.docker.com/storage/volumes/" rel="nofollow noreferrer">here</a>.</p>
<p>You can also use a docker-compose file like below</p>
<pre><code>version: '2.2'
services:
 fluentd:
    build: ./opt/app/
    container_name: fl01
    volumes:
      - &quot;/opt/app/conf/:/fluentd/etc/:ro&quot;
      - &quot;PATHTOYOURLOGFILE:/var/log/logf/&quot;
    networks:
      - elastic
    ports:
      - &quot;9880:9880&quot;
networks:
  elastic:
    driver: bridge
</code></pre>
