Friday, September 18, 2015

Setup docker for RSyslog

I'm going to talk about setup RSync for python (api_hour) application. But it is also related to any languages, actually I will build my article on docker for php. So you can use it for any service with logging.

As you maybe know docker team decide (??? needed link ???) that it is not good to have more than 1 service inside of docker so if you decide to use well known syslog inside of you app you should launch it separately. Because usually none of docker images comes with syslog inside.

I was playing with brand new engine for async python - api_hour and realize that it requires syslog.

So I have stared from one article that bind mount hosts of syslog docker with your server docker. But there other more easer solution it based on entrypoint, shared volumes and soft links (issue #4).

So in my case I have such launch script (shorten for example case):

echo '###########################################################################'
echo '# run syslog docker #'
echo '###########################################################################'
docker rm -f syslog
docker run --detach=true --name syslog helder/rsyslog
echo '###########################################################################'
echo '# run server docker #'
echo '###########################################################################'
docker run -i -t \
-p 8000:8000 \
--rm \
--volumes-from syslog \
--name web-server \
agg-web-server
logger -p local1.notice "This is a notice!"
view raw launch.sh hosted with ❤ by GitHub

you also should change

args=('/dev/log', handlers.SysLogHandler.LOG_LOCAL6)
view raw logging.org.ini hosted with ❤ by GitHub

to

args=('/dev/log', handlers.SysLogHandler.LOG_LOCAL1)
view raw logging.ini hosted with ❤ by GitHub

in etc/aggregator/api_hour/logging.ini.

After that you can check log output by

docker logs syslog
view raw run.sh hosted with ❤ by GitHub

Thanks all.

No comments :

Post a Comment