Getting Data In

Getting containerized universal forwarder to forward host log files

patrickkutch
New Member

I would like to be able to run the forwarder in a container, and have it forward my host logs from /var/log. So I mount the host /var/ into the container under /var/hostvar and run the container (in privileged mode) as such:

docker run -ti --rm --privileged -v /var:/var/hostvar --network host --env "SPLUNK_START_ARGS=--accept-license" --env "SPLUNK_FORWARD_SERVER=10.166.11.158:9997" --env "SPLUNK_PASSWORD=P@ssw0rd" --env "SPLUNK_ADD=/var/hostvar/log/" --name uf splunk/universalforwarder:latest

The directory is mapped correctly, however I get no data out of the forwarder (I can ping the splunk target from wthin the container) The problem seems to be that despite being marked as privileged, it cannot read my host kern.log file. I did a docker exec into the container to cat the file and I get:

#docker exec -ti uf cat /var/hostvar/log/kern.log
cat: /var/hostvar/log/kern.log: Permission denied

I tried to do the same thing (mount that directory, and cat the file) using busybox and it worked just fine.

Anybody have any thoughts?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...

Introduction to Splunk AI

How are you using AI in Splunk? Whether you see AI as a threat or opportunity, AI is here to stay. Lucky for ...