Solution without host bind mount #4

Closed
helderco opened this Issue Jul 19, 2015 · 2 comments

Projects

None yet

2 participants

@helderco

Hey, just wanted to share what I did to prevent the need for the host bind mount.

The idea is that I use a different location for the /dev/log socket, so that I can do --volumes-from without conflict. On another container, I just symlink /dev/log to that location. I also send the logs that I want to stderr so that I can do docker logs to get them.

syslog Dockerfile:

FROM debian:jessie

RUN apt-get update && \
    apt-get install rsyslog --no-install-recommends -y && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

COPY rsyslog.conf /etc/
VOLUME /var/run/rsyslog/dev

CMD ["rsyslogd", "-n"]

/etc/rsyslog.conf:

# load imuxsock module with alternative socket location
module(load="imuxsock")
input(type="imuxsock" Socket="/var/run/rsyslog/dev/log" CreatePath="on")

...

#
# Send your logs to stderr so that `docker logs` works
#
local1.*  {
    /proc/self/fd/2
    stop
}

Now, for example, in a PHP container you do --volumes-from syslog and run ln -sf /var/run/rsyslog/dev/log /dev/log (I do it in an entrypoint, but you get the idea of what needs to happen).

Example:

php:
  build: docker/php
  volumes_from:
    - syslog

syslog:
  image: helder/syslog

Now when my PHP container sends something to LOCAL1 using syslog, I get those with docker-compose logs syslog.

@jpetazzo
Owner
jpetazzo commented Aug 5, 2015

Oh, nice! If you wrote about this somewhere (blog post or whatever), I'd be happy to link to it from this project's documentation ... Or, maybe I could add this (and your name) in a markdown file linked from the toplevel README file?

@helderco
helderco commented Aug 6, 2015

Hey, the only documentation I have is in https://registry.hub.docker.com/u/helder/rsyslog/ and an example of a container using it with an entrypoint at the end of https://registry.hub.docker.com/u/helder/php/

@jpetazzo jpetazzo added a commit that closed this issue Sep 10, 2015
@jpetazzo Update README.md
Closes #4
2687f88
@jpetazzo jpetazzo closed this in 2687f88 Sep 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment