Getting output from cron-executed script into syslog / docker logging facility

349 views
Skip to first unread message

JT Zemp

unread,
Aug 14, 2017, 6:14:01 PM8/14/17
to passenger-docker
Hi, Passenger Docker peeps.

I've got a simple/quick test app that adds a script to the /home/app directory and a line to /etc/crontab that runs it every minute. The script outputs to stdout and syslog. The entries end up in /var/log/syslog inside the container, but aren't accessible via `docker logs -f $container`. Any thoughts on what I'm doing wrong or where to look next to see if it's a bug?

Thanks!

Dockerfile:

FROM phusion/passenger-ruby23:0.9.22
ENV HOME /root
CMD ["/sbin/my_init"]
COPY echo_me.sh cron_definition /home/app/
RUN cat /home/app/cron_definition >> /etc/crontab

echo_me.sh

#!/usr/bin/env bash
MESSAGE="I'm a script running in Docker cron. Kinda like Chaka Khan, but different. $(date)"
echo $MESSAGE >> log
logger $MESSAGE
echo "STDOUT ${MESSAGE}"

cron_definition

# every minute of every day for the rest of your life, run this script as the
# `app` user.
* * * * * app /home/app/echo_me.sh


When I build/run the image:

% docker build -t "docker-cron-test" .
% docker run "docker-cron-test"
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/30_presetup_nginx.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 9


I don't see any output here ^^

I can see that syslog is writing my output to the log
% docker exec -ti zealous_bartik bash -l
root@3f2c9ea0546e:/# less /var/log/syslog
root@3f2c9ea0546e:/# cat !$
cat /var/log/syslog
Aug 14 22:09:05 3f2c9ea0546e syslog-ng[16]: syslog-ng starting up; version='3.5.6'
Aug 14 22:10:01 3f2c9ea0546e CRON[25]: (app) CMD (/home/app/echo_me.sh)
Aug 14 22:10:01 3f2c9ea0546e app: I'm a script running in Docker cron. Kinda like Chaka Khan, but different. Mon Aug 14 22:10:01 UTC 2017
Aug 14 22:10:01 3f2c9ea0546e CRON[24]: (CRON) info (No MTA installed, discarding output)


But it's not getting out to docker logs:
% docker logs -f zealous_bartik
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/30_presetup_nginx.sh...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 9

Thoughts?

Thanks!
Reply all
Reply to author
Forward
0 new messages