I'm trying to gather logs from all my running docker containers and send them into the ELK stack. I'd like to use filebeat to do this so I'm following a similar approach to what is described in https://logz.io/blog/docker-logging/.
My filebeat.yml
filebeat:
inputs:
- paths:
- /var/jenkins_home/jobs/*/branches/*/builds/*/log
document_type: jenkinslog
- type: docker
containers.ids: '*'
document_type: docker
output:
logstash:
hosts: ["logstash:5044"]
My Dockerfile:
FROM docker.elastic.co/beats/filebeat:6.5.2
COPY filebeat.yml /usr/share/filebeat/filebeat.yml
USER root
RUN chown root:filebeat /usr/share/filebeat/filebeat.yml
My command to run this image:
docker run --rm --name filebeat_container --volumes-from jenkins_container:ro -v /var/lib/docker:/var/lib/docker --network=ttydinternproject_default filebeatimage
I'm mounting the /var/lib/docker folder as a volume and have to be root to access it as according to this https://github.com/hashicorp/vagrant/issues/6822#issuecomment-169826764 "/var/lib/docker is for the docker daemon and no one else.".
There must be a better way to get docker container logs into filebeat than to leave the filebeat container running root to access folders to apparently shouldn't even be accessed. Do I need to switch from the default docker logging driver to one of the other ones supported?