Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run as docker container? #5

Open
mattes opened this issue Jan 6, 2018 · 3 comments
Open

Run as docker container? #5

mattes opened this issue Jan 6, 2018 · 3 comments

Comments

@mattes
Copy link

mattes commented Jan 6, 2018

I'm trying to run systemd-netlogd inside a docker container. What sockets/files from the host machine would I need to mount into the docker container so that I can ship log data?

Is this approach infeasible?

@ssahani
Copy link
Collaborator

ssahani commented Jan 6, 2018

We open SD_JOURNAL_LOCAL_ONLY that is

"/run/log/journal\0"
    "/var/log/journal\0"

If can make access to these then it should work I guess. Not tested though.

@mattes
Copy link
Author

mattes commented Jan 6, 2018

I unfortunately wasn't able to get it to work. I'm going to post the things I've done here, maybe someone else wants to play around with it:

  1. Compile systemd-netlogd inside Docker container, see Dockerfile.
  2. Start container:
docker run -it --rm \
  -v /var/log/journal:/var/log/journal \
  -v /run/systemd/journal:/run/log/journal \
  -v /var/run/systemd:/var/run/systemd \
  -v $PWD/systemd-netlogd.conf:/etc/systemd/system/systemd-netlogd.conf \
  --privileged systemdnetlog bash
  1. Inside container I run (see strace)
cd /lib/systemd && ./systemd-netlogd
  1. On host machine I run:
logger "this is a test"

Now looking at the strace output, I see it's waiting on a epoll_wait, so I assume it's not reading the right files (maybe I mounted the wrong ones) or can't read them?

Please also note that the docker run command above is highly invasive, not suitable for prod usage.

Also, for reference I'm testing all of this on Google's Container-Optimized OS

@bobzoller
Copy link

I'm not using this project, but I traced through a similar issue and found I needed to to mount /etc/machine-id from the host (or at least mirror its contents) to my docker container to get it to work. here's the relevant bit of code in systemd.

HTH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants