1
0
mirror of /repos/baseimage-docker.git synced 2025-12-30 08:01:31 +01:00

Redirect syslog to 'docker logs' and fix cron

Closes GH-123. Closes GH-115.
This commit is contained in:
Hongli Lai (Phusion) 2015-01-19 18:07:15 +01:00
parent 0b2de757f5
commit 6e55e3d515
No known key found for this signature in database
GPG Key ID: 2AF96EB85EF4DA0D
6 changed files with 53 additions and 2 deletions

View File

@ -1,9 +1,11 @@
## 0.9.16 (next version, not yet released)
* `docker exec` is now the default and recommended mechanism for running commands in the container. SSH is now disabled by default, but is still supported for those cases where "docker exec" is not appropriate. Closes GH-168.
* All syslog output is now forwarded to `docker logs`. Closes GH-123.
* The workaround for Docker bug 2267 (the inability to modify /etc/hosts) has been removed, because it has been fixed upstream. Closes GH-155.
* Logrotate now reloads syslog-ng properly. Closes GH-167.
* Fixed some locale issues. Closes GH-178. Thanks to David J. M. Karlsen.
* Fixed problems with cron. Closes GH-115.
## 0.9.15 (release date: 2014-10-03)

View File

@ -82,7 +82,7 @@ You can configure the stock `ubuntu` image yourself from your Dockerfile, so why
| Ubuntu 14.04 LTS | The base system. |
| A **correct** init process | According to the Unix process model, [the init process](https://en.wikipedia.org/wiki/Init) -- PID 1 -- inherits all [orphaned child processes](https://en.wikipedia.org/wiki/Orphan_process) and must [reap them](https://en.wikipedia.org/wiki/Wait_(system_call)). Most Docker containers do not have an init process that does this correctly, and as a result their containers become filled with [zombie processes](https://en.wikipedia.org/wiki/Zombie_process) over time. <br><br>Furthermore, `docker stop` sends SIGTERM to the init process, which is then supposed to stop all services. Unfortunately most init systems don't do this correctly within Docker since they're built for hardware shutdowns instead. This causes processes to be hard killed with SIGKILL, which doesn't give them a chance to correctly deinitialize things. This can cause file corruption. <br><br>Baseimage-docker comes with an init process `/sbin/my_init` that performs both of these tasks correctly. |
| Fixes APT incompatibilities with Docker | See https://github.com/dotcloud/docker/issues/1024. |
| syslog-ng | A syslog daemon is necessary so that many services - including the kernel itself - can correctly log to /var/log/syslog. If no syslog daemon is running, a lot of important messages are silently swallowed. <br><br>Only listens locally. |
| syslog-ng | A syslog daemon is necessary so that many services - including the kernel itself - can correctly log to /var/log/syslog. If no syslog daemon is running, a lot of important messages are silently swallowed. <br><br>Only listens locally. All syslog messages are forwarded to "docker logs". |
| logrotate | Rotates and compresses logs on a regular basis. |
| SSH server | Allows you to easily login to your container to [inspect or administer](#login_ssh) things. <br><br>_SSH is **disabled by default** and is only one of the methods provided by baseimage-docker for this purpose. The other method is through [docker exec](#login_docker_exec). SSH is also provided as an alternative because `docker exec` comes with several caveats._<br><br>Password and challenge-response authentication are disabled by default. Only key authentication is allowed. |
| cron | The cron daemon must be running for cron jobs to work. |

View File

@ -0,0 +1,38 @@
/var/log/syslog
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
postrotate
sv reload syslog-ng > /dev/null
endscript
}
/var/log/mail.info
/var/log/mail.warn
/var/log/mail.err
/var/log/mail.log
/var/log/daemon.log
/var/log/kern.log
/var/log/auth.log
/var/log/user.log
/var/log/lpr.log
/var/log/cron.log
/var/log/debug
/var/log/messages
{
rotate 4
weekly
missingok
notifempty
compress
delaycompress
sharedscripts
postrotate
sv reload syslog-ng > /dev/null
sv restart cron-log-forwarder > /dev/null
endscript
}

View File

@ -45,3 +45,5 @@ apt-get dist-upgrade -y --no-install-recommends
$minimal_apt_get_install language-pack-en
locale-gen en_US
update-locale LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8
echo -n en_US.UTF-8 > /etc/container_environment/LANG
echo -n en_US.UTF-8 > /etc/container_environment/LC_CTYPE

2
image/runit/syslog-forwarder Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
exec tail -f -n 0 /var/log/syslog

View File

@ -25,13 +25,19 @@ mkdir /etc/service/syslog-ng
cp /build/runit/syslog-ng /etc/service/syslog-ng/run
mkdir -p /var/lib/syslog-ng
cp /build/config/syslog_ng_default /etc/default/syslog-ng
touch /var/log/syslog
chmod u=rw,g=r,o= /var/log/syslog
# Replace the system() source because inside Docker we
# can't access /proc/kmsg.
sed -i -E 's/^(\s*)system\(\);/\1unix-stream("\/dev\/log");/' /etc/syslog-ng/syslog-ng.conf
## Install syslog to "docker logs" forwarder.
mkdir /etc/service/syslog-forwarder
cp /build/runit/syslog-forwarder /etc/service/syslog-forwarder/run
## Install logrotate.
$minimal_apt_get_install logrotate
sed -i 's|invoke-rc.d syslog-ng reload|sv reload syslog-ng|g' /etc/logrotate.d/syslog-ng
cp /build/config/logrotate_syslogng /etc/logrotate.d/syslog-ng
## Install the SSH server.
$minimal_apt_get_install openssh-server
@ -55,6 +61,7 @@ cp /build/bin/enable_insecure_key /usr/sbin/
## Install cron daemon.
$minimal_apt_get_install cron
mkdir /etc/service/cron
chmod 600 /etc/crontab
cp /build/runit/cron /etc/service/cron/run
## Remove useless cron entries.