I am trying to setup promtail
as part of my docker-compose setup to collect my Rails logs.
This is the promtail
part of my docker-compose.yml
:
promtail:
image: grafana/promtail:3.0.0
volumes:
- ./docker/promtail/config.yml:/etc/promtail/config.yml
- ./log:/var/log/rails
command: -config.file=/etc/promtail/config.yml
When I start the image:
docker-compose up promtail
I see the files on the image: /var/log/rails
are updated:
docker-compose exec promtail tail /var/log/rails/development.log
Then I make some requests to my app, and new logs are added in my local files (host, outside the Docker):
tail ./logs/development.log
But the new logs are replicated in the same file in the Docker image:
docker-compose exec promtail tail /var/log/rails/development.log
I can continue generating logs through my Rails app, but the logs are not replicated in the log file in my image.
The interesting part is that if I execute this in the host (outside the Docker):
echo "XXX" >> ./log/development.log
Suddenly, all the logs are replicated in my Docker image.
How can I make sure the log files are replicated inside the Docker image when they are updated outside?