From 160987c73c3c9c13a7bc154a2afcd9b4db716c42 Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Sat, 21 Nov 2026 11:49:49 +0000 Subject: [PATCH 1/3] [BUGFIX] Send the remaining logs of the services to the container log Some logs of the services did not reach the container log, or not the files of LOG_STDOUT and LOG_STDERR: - Cron in Debian and Ubuntu mails the output of a job. Without a mail server it discarded it ("No MTA installed, discarding output"); in the development images Postfix delivered it to /var/mail/. docker-cronjob now begins /etc/cron.d/webdevops-docker with SHELL=/usr/local/bin/docker-cronjob-shell. The new script runs the job with /bin/sh and sends its stdout and stderr, line by line, to syslog, from where syslog-ng writes them to the container log. It keeps the exit code of the job and waits up to 10 seconds for syslog-ng, for @reboot jobs, which cron runs as soon as it starts. - sshd logs to syslog with the facility auth, which syslog-ng drops. It now runs with -e and logs to its stderr. - What the services print to their stdout and stderr, for example the output of cron jobs in Alpine, the Blackfire agent and sshd, went to the container log also with LOG_STDOUT and LOG_STDERR. supervisord now writes it to /docker.stdout and /docker.stderr, which are the stdout and stderr of the container without the two variables. - Nginx in Alpine wrote its main error log, e.g. a worker process that ended on a signal, to /docker.stdout; now to /docker.stderr. The image tests check each case in the environment container. The docs describe where each service logs, the output of cron jobs, and as known issues the crontab files of your own in Debian and Ubuntu and the slow log of PHP-FPM without SYS_PTRACE. --- AGENTS.md | 2 +- .../Checks/ContainerEnvironmentChecks.php | 48 +++++++++++++++++++ .../Checks/NginxEnvironmentChecks.php | 19 ++++++++ ci/image-tests/Checks/SshChecks.php | 21 +++++++- .../Hooks/entrypoint.d/70-image-test-cron.sh | 8 ++++ .../service.d/syslog-ng.d/50-image-test.sh | 3 ++ .../ubuntu-22.04/conf/bin/service.d/ssh.sh | 4 +- .../conf/bin/usr-bin/docker-cronjob | 6 +++ .../conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../conf/etc/supervisor.d/cron.conf | 5 +- .../conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../conf/etc/supervisor.d/postfix.conf | 5 +- .../conf/etc/supervisor.d/ssh.conf | 5 +- .../conf/etc/supervisor.d/syslog.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../conf/etc/supervisor.d/apache.conf | 5 +- .../8.2/conf/etc/supervisor.d/apache.conf | 5 +- .../conf/etc/supervisor.d/apache.conf | 5 +- .../8.3/conf/etc/supervisor.d/apache.conf | 5 +- .../conf/etc/supervisor.d/apache.conf | 5 +- .../8.4/conf/etc/supervisor.d/apache.conf | 5 +- .../conf/etc/supervisor.d/apache.conf | 5 +- .../8.5/conf/etc/supervisor.d/apache.conf | 5 +- .../conf/etc/supervisor.d/apache.conf | 5 +- .../8.6/conf/etc/supervisor.d/apache.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../8.2-alpine/conf/etc/nginx/nginx.conf | 2 +- .../conf/etc/supervisor.d/nginx.conf | 5 +- .../8.2/conf/etc/supervisor.d/nginx.conf | 5 +- .../8.3-alpine/conf/etc/nginx/nginx.conf | 2 +- .../conf/etc/supervisor.d/nginx.conf | 5 +- .../8.3/conf/etc/supervisor.d/nginx.conf | 5 +- .../8.4-alpine/conf/etc/nginx/nginx.conf | 2 +- .../conf/etc/supervisor.d/nginx.conf | 5 +- .../8.4/conf/etc/supervisor.d/nginx.conf | 5 +- .../8.5-alpine/conf/etc/nginx/nginx.conf | 2 +- .../conf/etc/supervisor.d/nginx.conf | 5 +- .../8.5/conf/etc/supervisor.d/nginx.conf | 5 +- .../8.6-alpine/conf/etc/nginx/nginx.conf | 2 +- .../conf/etc/supervisor.d/nginx.conf | 5 +- .../8.6/conf/etc/supervisor.d/nginx.conf | 5 +- .../php/8.2-alpine/conf/bin/service.d/ssh.sh | 4 +- .../conf/bin/usr-bin/docker-cronjob | 6 +++ .../conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../conf/etc/supervisor.d/cron.conf | 5 +- .../conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../conf/etc/supervisor.d/php-fpm.conf | 5 +- .../conf/etc/supervisor.d/postfix.conf | 5 +- .../8.2-alpine/conf/etc/supervisor.d/ssh.conf | 5 +- .../conf/etc/supervisor.d/syslog.conf | 5 +- docker/php/8.2/conf/bin/service.d/ssh.sh | 4 +- .../php/8.2/conf/bin/usr-bin/docker-cronjob | 6 +++ .../8.2/conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../php/8.2/conf/etc/supervisor.d/cron.conf | 5 +- .../8.2/conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../8.2/conf/etc/supervisor.d/php-fpm.conf | 5 +- .../8.2/conf/etc/supervisor.d/postfix.conf | 5 +- docker/php/8.2/conf/etc/supervisor.d/ssh.conf | 5 +- .../php/8.2/conf/etc/supervisor.d/syslog.conf | 5 +- .../php/8.3-alpine/conf/bin/service.d/ssh.sh | 4 +- .../conf/bin/usr-bin/docker-cronjob | 6 +++ .../conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../conf/etc/supervisor.d/cron.conf | 5 +- .../conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../conf/etc/supervisor.d/php-fpm.conf | 5 +- .../conf/etc/supervisor.d/postfix.conf | 5 +- .../8.3-alpine/conf/etc/supervisor.d/ssh.conf | 5 +- .../conf/etc/supervisor.d/syslog.conf | 5 +- docker/php/8.3/conf/bin/service.d/ssh.sh | 4 +- .../php/8.3/conf/bin/usr-bin/docker-cronjob | 6 +++ .../8.3/conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../php/8.3/conf/etc/supervisor.d/cron.conf | 5 +- .../8.3/conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../8.3/conf/etc/supervisor.d/php-fpm.conf | 5 +- .../8.3/conf/etc/supervisor.d/postfix.conf | 5 +- docker/php/8.3/conf/etc/supervisor.d/ssh.conf | 5 +- .../php/8.3/conf/etc/supervisor.d/syslog.conf | 5 +- .../php/8.4-alpine/conf/bin/service.d/ssh.sh | 4 +- .../conf/bin/usr-bin/docker-cronjob | 6 +++ .../conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../conf/etc/supervisor.d/cron.conf | 5 +- .../conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../conf/etc/supervisor.d/php-fpm.conf | 5 +- .../conf/etc/supervisor.d/postfix.conf | 5 +- .../8.4-alpine/conf/etc/supervisor.d/ssh.conf | 5 +- .../conf/etc/supervisor.d/syslog.conf | 5 +- docker/php/8.4/conf/bin/service.d/ssh.sh | 4 +- .../php/8.4/conf/bin/usr-bin/docker-cronjob | 6 +++ .../8.4/conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../php/8.4/conf/etc/supervisor.d/cron.conf | 5 +- .../8.4/conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../8.4/conf/etc/supervisor.d/php-fpm.conf | 5 +- .../8.4/conf/etc/supervisor.d/postfix.conf | 5 +- docker/php/8.4/conf/etc/supervisor.d/ssh.conf | 5 +- .../php/8.4/conf/etc/supervisor.d/syslog.conf | 5 +- .../php/8.5-alpine/conf/bin/service.d/ssh.sh | 4 +- .../conf/bin/usr-bin/docker-cronjob | 6 +++ .../conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../conf/etc/supervisor.d/cron.conf | 5 +- .../conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../conf/etc/supervisor.d/php-fpm.conf | 5 +- .../conf/etc/supervisor.d/postfix.conf | 5 +- .../8.5-alpine/conf/etc/supervisor.d/ssh.conf | 5 +- .../conf/etc/supervisor.d/syslog.conf | 5 +- docker/php/8.5/conf/bin/service.d/ssh.sh | 4 +- .../php/8.5/conf/bin/usr-bin/docker-cronjob | 6 +++ .../8.5/conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../php/8.5/conf/etc/supervisor.d/cron.conf | 5 +- .../8.5/conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../8.5/conf/etc/supervisor.d/php-fpm.conf | 5 +- .../8.5/conf/etc/supervisor.d/postfix.conf | 5 +- docker/php/8.5/conf/etc/supervisor.d/ssh.conf | 5 +- .../php/8.5/conf/etc/supervisor.d/syslog.conf | 5 +- .../php/8.6-alpine/conf/bin/service.d/ssh.sh | 4 +- .../conf/bin/usr-bin/docker-cronjob | 6 +++ .../conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../conf/etc/supervisor.d/cron.conf | 5 +- .../conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../conf/etc/supervisor.d/php-fpm.conf | 5 +- .../conf/etc/supervisor.d/postfix.conf | 5 +- .../8.6-alpine/conf/etc/supervisor.d/ssh.conf | 5 +- .../conf/etc/supervisor.d/syslog.conf | 5 +- docker/php/8.6/conf/bin/service.d/ssh.sh | 4 +- .../php/8.6/conf/bin/usr-bin/docker-cronjob | 6 +++ .../8.6/conf/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../php/8.6/conf/etc/supervisor.d/cron.conf | 5 +- .../8.6/conf/etc/supervisor.d/dnsmasq.conf | 5 +- .../8.6/conf/etc/supervisor.d/php-fpm.conf | 5 +- .../8.6/conf/etc/supervisor.d/postfix.conf | 5 +- docker/php/8.6/conf/etc/supervisor.d/ssh.conf | 5 +- .../php/8.6/conf/etc/supervisor.d/syslog.conf | 5 +- docs/README.md | 2 +- docs/customization.md | 26 +++++++++- docs/environment-variables.md | 6 +-- docs/images/php.md | 2 +- docs/known-issues.md | 22 +++++++++ .../general/etc/supervisor.d/apache.conf | 5 +- .../base/general/bin/service.d/ssh.sh | 4 +- .../base/general/bin/usr-bin/docker-cronjob | 6 +++ .../general/bin/usr-bin/docker-cronjob-shell | 28 +++++++++++ .../base/general/etc/supervisor.d/cron.conf | 5 +- .../general/etc/supervisor.d/dnsmasq.conf | 5 +- .../general/etc/supervisor.d/postfix.conf | 5 +- .../base/general/etc/supervisor.d/ssh.conf | 5 +- .../base/general/etc/supervisor.d/syslog.conf | 5 +- .../nginx/alpine/etc/nginx/nginx.conf | 2 +- .../nginx/general/etc/supervisor.d/nginx.conf | 5 +- .../etc/supervisor.d/blackfire-agent.conf | 5 +- .../php/general/etc/supervisor.d/php-fpm.conf | 5 +- 177 files changed, 972 insertions(+), 275 deletions(-) create mode 100644 docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell create mode 100644 provisioning/base/general/bin/usr-bin/docker-cronjob-shell diff --git a/AGENTS.md b/AGENTS.md index ac0793b91..77b21c6f3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -64,7 +64,7 @@ Where the documentation lives: | `CONTRIBUTING.md` | Build process: the generated files and `make generate`, the CI and `make check`, building and testing locally, the image tests, PHP extension builds | | `docs/README.md` | Image overview, platforms and nightly updates, how the images build on each other (Mermaid diagram) | | `docs/environment-variables.md` | Every environment variable with its default and effect; uploads and long requests | -| `docs/customization.md` | Commands, scripts at start and build time, tools for your Dockerfile, services, cron jobs and their time zone, healthcheck, configuration files and placeholders, supervisord, locales, application user and changing its UID | +| `docs/customization.md` | Commands, scripts at start and build time, tools for your Dockerfile, services and their logs, cron jobs, their output and their time zone, healthcheck, configuration files and placeholders, supervisord, locales, application user and changing its UID | | `docs/images/*.md` | One page per image family: tags, base image, services, settings, development variant. `php.md` also has Debian or Alpine, production, installing extensions, mail and Xdebug with an IDE | | `docs/known-issues.md` | Options and tools that do not work, with affected images and workaround; migration from older images | | `docs/discontinued-images.md` | Replacements for images and tags that are no longer built (`nginx`, `apache`, the `alpine` tags of `bootstrap`, `base` and `base-app`, `storage`, `vsftp`, `ssh`) or deprecated (`php-official`) | diff --git a/ci/image-tests/Checks/ContainerEnvironmentChecks.php b/ci/image-tests/Checks/ContainerEnvironmentChecks.php index 04fc34062..7109d6544 100644 --- a/ci/image-tests/Checks/ContainerEnvironmentChecks.php +++ b/ci/image-tests/Checks/ContainerEnvironmentChecks.php @@ -98,6 +98,54 @@ public function testSyslogMessagesReachTheFileFromTheEnvironment(): void }); } + /** + * The output of a cron job that docker-cronjob added, from Hooks/, reaches the files of LOG_STDOUT and LOG_STDERR. + * Cron in Debian and Ubuntu would mail it, or discard it without a mail server: docker-cronjob-shell passes both + * lines to syslog-ng, which writes them to the file of LOG_STDOUT. BusyBox crond on Alpine passes on its own stdout + * and stderr, which supervisord writes to the two files. Only in the images that start cron. + */ + public function testCronJobOutputReachesTheFilesFromTheEnvironment(): void + { + if (!in_array('cron', self::services(), true)) { + self::markTestSkipped('The image does not start cron.'); + } + + $container = $this->environmentContainer(); + // the job writes the lines in upper case, so they differ from its command, which cron logs + [$output, $error] = ['IMAGE-TEST-CRON-OUTPUT', 'IMAGE-TEST-CRON-ERROR']; + // cron runs the job at the start of a minute + $this->waitFor(function () use ($container, $output, $error): void { + $stdout = $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container); + $stderr = $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container); + if (self::image()->isAlpine()) { + self::assertMatchesRegularExpression('/^' . $output . '$/m', $stdout); + self::assertMatchesRegularExpression('/^' . $error . '$/m', $stderr); + } else { + self::assertMatchesRegularExpression('/ cron-job\[\d+\]: ' . $output . '$/m', $stdout); + self::assertMatchesRegularExpression('/ cron-job\[\d+\]: ' . $error . '$/m', $stdout); + } + }, 25, 3); + } + + /** + * What a service writes to its stdout and stderr reaches the files of LOG_STDOUT and LOG_STDERR: supervisord writes + * it there. The hook of syslog-ng from Hooks/ writes a line to each. The environment container starts syslog-ng + * where the image does not. At the log level trace of SERVICE_SUPERVISOR_OPTS, supervisord also repeats the output + * of the services in its own messages in the container log, so the container log is not checked here. + */ + public function testServiceOutputReachesTheFilesFromTheEnvironment(): void + { + $container = $this->environmentContainer(); + if (!in_array('syslog', self::services(), true)) { + $this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container); + } + + $this->eventually(function () use ($container): void { + self::assertStringContainsString('image-test: the hook of syslog-ng on stdout', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container)); + self::assertStringContainsString('image-test: the hook of syslog-ng on stderr', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container)); + }); + } + /** * /docker.stdout and /docker.stderr, where the services of the image write their logs, point to the files of * LOG_STDOUT and LOG_STDERR. diff --git a/ci/image-tests/Checks/NginxEnvironmentChecks.php b/ci/image-tests/Checks/NginxEnvironmentChecks.php index 2ef9e9ab8..3303bd1d2 100644 --- a/ci/image-tests/Checks/NginxEnvironmentChecks.php +++ b/ci/image-tests/Checks/NginxEnvironmentChecks.php @@ -52,4 +52,23 @@ public function testNginxLogsToTheFilesFromTheEnvironment(): void self::assertMatchesRegularExpression('#\[error\] .*image-test-forbidden\.html" failed \(13: Permission denied\)#', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container)); }); } + + /** + * Nginx writes the messages that belong to no server, those of its main error log, to LOG_STDERR, not to LOG_STDOUT: + * the master process logs that a worker process ended on SIGKILL. + */ + public function testNginxMainErrorLogToTheFileFromTheEnvironment(): void + { + $container = $this->environmentContainer(); + $this->request('http://localhost/', container: $container); + $this->assertCommandSucceeds( + 'for process in /proc/[0-9]*; do if tr "\\000" " " < $process/cmdline 2>/dev/null | grep -q "^nginx: worker process"; then kill -9 ${process#/proc/}; break; fi; done', + $container, + ); + $exited = '#\[alert\] .*worker process \d+ exited on signal 9#'; + $this->eventually(function () use ($container, $exited): void { + self::assertMatchesRegularExpression($exited, $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container)); + }); + self::assertDoesNotMatchRegularExpression($exited, $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container)); + } } diff --git a/ci/image-tests/Checks/SshChecks.php b/ci/image-tests/Checks/SshChecks.php index 691da54fe..2ef4cd24c 100644 --- a/ci/image-tests/Checks/SshChecks.php +++ b/ci/image-tests/Checks/SshChecks.php @@ -4,13 +4,14 @@ namespace Webdevops\Build\ImageTests\Checks; +use Webdevops\Build\ImageTests\Docker\ListeningSockets; use Webdevops\Build\ImageTests\ImageTestCase; use function implode; /** * The SSH server of the development images runs, listens on port 22 and lets root and the application user log in with - * the password dev. + * the password dev. Its log reaches the file of LOG_STDERR. * * @phpstan-require-extends ImageTestCase */ @@ -37,4 +38,22 @@ public function testSshLoginWithThePasswordDev(): void ])); self::assertSame([0, "application\n"], [$result->exitCode, $result->stdout], $result->describe()); } + + /** + * sshd logs to its stderr, which supervisord writes to the file of LOG_STDERR in the environment container, where + * sshd listens on port 2222 (SERVICE_SSH_OPTS). Through syslog, its messages were lost: syslog-ng drops the facility + * auth. + */ + public function testSshLogsToTheFileFromTheEnvironment(): void + { + $container = $this->environmentContainer(); + $this->eventually(function () use ($container): void { + self::assertTrue(ListeningSockets::read($container)->isListening(2222), 'sshd should listen on port 2222'); + }); + $login = $this->execute('ssh -o BatchMode=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 2222 image-test-nobody@127.0.0.1 true', $container); + self::assertNotSame(0, $login->exitCode, $login->describe()); + $this->eventually(function () use ($container): void { + self::assertMatchesRegularExpression('/Invalid user image-test-nobody from 127\.0\.0\.1 /', $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container)); + }); + } } diff --git a/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh b/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh index 808cafb26..59ff7c6c9 100644 --- a/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh +++ b/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh @@ -1,6 +1,8 @@ # Image tests: with IMAGE_TEST_CRON set to hours, e.g. "9,10", adds a cron job for these hours before cron starts, which # marks that it ran, see ContainerEnvironmentChecks. The tests set the current and the next hour in Berlin, worked out # outside the image, so cron runs the job only if it uses the time zone of TZ. +# It also adds a job with docker-cronjob that writes a line to stdout and one to stderr every minute, in upper case, so +# that the lines differ from the command, which cron logs. if [[ -n "${IMAGE_TEST_CRON:-}" ]]; then if [[ -d /etc/crontabs ]]; then # BusyBox crond on Alpine @@ -9,4 +11,10 @@ if [[ -n "${IMAGE_TEST_CRON:-}" ]]; then echo "* ${IMAGE_TEST_CRON} * * * root echo ran > /tmp/image-tests/cron-job" > /etc/cron.d/image-test chmod 644 /etc/cron.d/image-test fi + + # where docker-cronjob fails, as on Alpine before it wrote to /etc/crontabs, the container starts all the same; the + # test of the output fails then + if id application > /dev/null 2>&1; then + docker-cronjob '* * * * * application echo image-test-cron-output | tr a-z A-Z; echo image-test-cron-error | tr a-z A-Z >&2' || true + fi fi diff --git a/ci/image-tests/Hooks/opt/docker/bin/service.d/syslog-ng.d/50-image-test.sh b/ci/image-tests/Hooks/opt/docker/bin/service.d/syslog-ng.d/50-image-test.sh index d1d87a6e8..27927f0b4 100644 --- a/ci/image-tests/Hooks/opt/docker/bin/service.d/syslog-ng.d/50-image-test.sh +++ b/ci/image-tests/Hooks/opt/docker/bin/service.d/syslog-ng.d/50-image-test.sh @@ -1,3 +1,6 @@ # Image tests: marks that a service sourced the hooks in its directory, and as which user, see ServiceChecks mkdir -p /tmp/image-tests/hooks id -un > "/tmp/image-tests/hooks/$(basename "$(dirname "${BASH_SOURCE[0]}")")" +# and writes a line to the stdout and one to the stderr of the service, see ContainerEnvironmentChecks +echo "image-test: the hook of syslog-ng on stdout" +echo "image-test: the hook of syslog-ng on stderr" >&2 diff --git a/docker/base/ubuntu-22.04/conf/bin/service.d/ssh.sh b/docker/base/ubuntu-22.04/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/base/ubuntu-22.04/conf/bin/service.d/ssh.sh +++ b/docker/base/ubuntu-22.04/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob +++ b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/cron.conf b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/cron.conf +++ b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/dnsmasq.conf b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/postfix.conf b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/postfix.conf +++ b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/ssh.conf b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/ssh.conf +++ b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/syslog.conf b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/base/ubuntu-22.04/conf/etc/supervisor.d/syslog.conf +++ b/docker/base/ubuntu-22.04/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-apache-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-apache-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-apache-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.2-alpine/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.2-alpine/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.2-alpine/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.2-alpine/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.2/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.2/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.2/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.2/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.3-alpine/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.3-alpine/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.3-alpine/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.3-alpine/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.3/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.3/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.3/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.3/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.4-alpine/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.4-alpine/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.4-alpine/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.4-alpine/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.4/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.4/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.4/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.4/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.5-alpine/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.5-alpine/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.5-alpine/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.5-alpine/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.5/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.5/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.5/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.5/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.6-alpine/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.6-alpine/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.6-alpine/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.6-alpine/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-apache/8.6/conf/etc/supervisor.d/apache.conf b/docker/php-apache/8.6/conf/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/docker/php-apache/8.6/conf/etc/supervisor.d/apache.conf +++ b/docker/php-apache/8.6/conf/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.2-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.2/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.3-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.3/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.4-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.4/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.5-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.5/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.6-alpine/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf b/docker/php-nginx-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/docker/php-nginx-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf +++ b/docker/php-nginx-dev/8.6/conf/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.2-alpine/conf/etc/nginx/nginx.conf b/docker/php-nginx/8.2-alpine/conf/etc/nginx/nginx.conf index b9cb4ebc4..981590f32 100644 --- a/docker/php-nginx/8.2-alpine/conf/etc/nginx/nginx.conf +++ b/docker/php-nginx/8.2-alpine/conf/etc/nginx/nginx.conf @@ -4,7 +4,7 @@ user nginx; worker_processes auto; -error_log /docker.stdout; +error_log /docker.stderr; pid /run/nginx.pid; events { diff --git a/docker/php-nginx/8.2-alpine/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.2-alpine/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.2-alpine/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.2-alpine/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.2/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.2/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.2/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.2/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.3-alpine/conf/etc/nginx/nginx.conf b/docker/php-nginx/8.3-alpine/conf/etc/nginx/nginx.conf index b9cb4ebc4..981590f32 100644 --- a/docker/php-nginx/8.3-alpine/conf/etc/nginx/nginx.conf +++ b/docker/php-nginx/8.3-alpine/conf/etc/nginx/nginx.conf @@ -4,7 +4,7 @@ user nginx; worker_processes auto; -error_log /docker.stdout; +error_log /docker.stderr; pid /run/nginx.pid; events { diff --git a/docker/php-nginx/8.3-alpine/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.3-alpine/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.3-alpine/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.3-alpine/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.3/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.3/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.3/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.3/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.4-alpine/conf/etc/nginx/nginx.conf b/docker/php-nginx/8.4-alpine/conf/etc/nginx/nginx.conf index b9cb4ebc4..981590f32 100644 --- a/docker/php-nginx/8.4-alpine/conf/etc/nginx/nginx.conf +++ b/docker/php-nginx/8.4-alpine/conf/etc/nginx/nginx.conf @@ -4,7 +4,7 @@ user nginx; worker_processes auto; -error_log /docker.stdout; +error_log /docker.stderr; pid /run/nginx.pid; events { diff --git a/docker/php-nginx/8.4-alpine/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.4-alpine/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.4-alpine/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.4-alpine/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.4/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.4/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.4/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.4/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.5-alpine/conf/etc/nginx/nginx.conf b/docker/php-nginx/8.5-alpine/conf/etc/nginx/nginx.conf index b9cb4ebc4..981590f32 100644 --- a/docker/php-nginx/8.5-alpine/conf/etc/nginx/nginx.conf +++ b/docker/php-nginx/8.5-alpine/conf/etc/nginx/nginx.conf @@ -4,7 +4,7 @@ user nginx; worker_processes auto; -error_log /docker.stdout; +error_log /docker.stderr; pid /run/nginx.pid; events { diff --git a/docker/php-nginx/8.5-alpine/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.5-alpine/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.5-alpine/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.5-alpine/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.5/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.5/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.5/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.5/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.6-alpine/conf/etc/nginx/nginx.conf b/docker/php-nginx/8.6-alpine/conf/etc/nginx/nginx.conf index b9cb4ebc4..981590f32 100644 --- a/docker/php-nginx/8.6-alpine/conf/etc/nginx/nginx.conf +++ b/docker/php-nginx/8.6-alpine/conf/etc/nginx/nginx.conf @@ -4,7 +4,7 @@ user nginx; worker_processes auto; -error_log /docker.stdout; +error_log /docker.stderr; pid /run/nginx.pid; events { diff --git a/docker/php-nginx/8.6-alpine/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.6-alpine/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.6-alpine/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.6-alpine/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php-nginx/8.6/conf/etc/supervisor.d/nginx.conf b/docker/php-nginx/8.6/conf/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/docker/php-nginx/8.6/conf/etc/supervisor.d/nginx.conf +++ b/docker/php-nginx/8.6/conf/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2-alpine/conf/bin/service.d/ssh.sh b/docker/php/8.2-alpine/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.2-alpine/conf/bin/service.d/ssh.sh +++ b/docker/php/8.2-alpine/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.2-alpine/conf/etc/supervisor.d/cron.conf b/docker/php/8.2-alpine/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.2-alpine/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.2-alpine/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2-alpine/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.2-alpine/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.2-alpine/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.2-alpine/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2-alpine/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.2-alpine/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.2-alpine/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.2-alpine/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2-alpine/conf/etc/supervisor.d/postfix.conf b/docker/php/8.2-alpine/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.2-alpine/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.2-alpine/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2-alpine/conf/etc/supervisor.d/ssh.conf b/docker/php/8.2-alpine/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.2-alpine/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.2-alpine/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2-alpine/conf/etc/supervisor.d/syslog.conf b/docker/php/8.2-alpine/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.2-alpine/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.2-alpine/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2/conf/bin/service.d/ssh.sh b/docker/php/8.2/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.2/conf/bin/service.d/ssh.sh +++ b/docker/php/8.2/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.2/conf/etc/supervisor.d/cron.conf b/docker/php/8.2/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.2/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.2/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.2/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.2/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.2/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.2/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.2/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.2/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2/conf/etc/supervisor.d/postfix.conf b/docker/php/8.2/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.2/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.2/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2/conf/etc/supervisor.d/ssh.conf b/docker/php/8.2/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.2/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.2/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.2/conf/etc/supervisor.d/syslog.conf b/docker/php/8.2/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.2/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.2/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3-alpine/conf/bin/service.d/ssh.sh b/docker/php/8.3-alpine/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.3-alpine/conf/bin/service.d/ssh.sh +++ b/docker/php/8.3-alpine/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.3-alpine/conf/etc/supervisor.d/cron.conf b/docker/php/8.3-alpine/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.3-alpine/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.3-alpine/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3-alpine/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.3-alpine/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.3-alpine/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.3-alpine/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3-alpine/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.3-alpine/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.3-alpine/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.3-alpine/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3-alpine/conf/etc/supervisor.d/postfix.conf b/docker/php/8.3-alpine/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.3-alpine/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.3-alpine/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3-alpine/conf/etc/supervisor.d/ssh.conf b/docker/php/8.3-alpine/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.3-alpine/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.3-alpine/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3-alpine/conf/etc/supervisor.d/syslog.conf b/docker/php/8.3-alpine/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.3-alpine/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.3-alpine/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3/conf/bin/service.d/ssh.sh b/docker/php/8.3/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.3/conf/bin/service.d/ssh.sh +++ b/docker/php/8.3/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.3/conf/etc/supervisor.d/cron.conf b/docker/php/8.3/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.3/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.3/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.3/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.3/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.3/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.3/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.3/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.3/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3/conf/etc/supervisor.d/postfix.conf b/docker/php/8.3/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.3/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.3/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3/conf/etc/supervisor.d/ssh.conf b/docker/php/8.3/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.3/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.3/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.3/conf/etc/supervisor.d/syslog.conf b/docker/php/8.3/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.3/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.3/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4-alpine/conf/bin/service.d/ssh.sh b/docker/php/8.4-alpine/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.4-alpine/conf/bin/service.d/ssh.sh +++ b/docker/php/8.4-alpine/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.4-alpine/conf/etc/supervisor.d/cron.conf b/docker/php/8.4-alpine/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.4-alpine/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.4-alpine/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4-alpine/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.4-alpine/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.4-alpine/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.4-alpine/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4-alpine/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.4-alpine/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.4-alpine/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.4-alpine/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4-alpine/conf/etc/supervisor.d/postfix.conf b/docker/php/8.4-alpine/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.4-alpine/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.4-alpine/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4-alpine/conf/etc/supervisor.d/ssh.conf b/docker/php/8.4-alpine/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.4-alpine/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.4-alpine/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4-alpine/conf/etc/supervisor.d/syslog.conf b/docker/php/8.4-alpine/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.4-alpine/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.4-alpine/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4/conf/bin/service.d/ssh.sh b/docker/php/8.4/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.4/conf/bin/service.d/ssh.sh +++ b/docker/php/8.4/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.4/conf/etc/supervisor.d/cron.conf b/docker/php/8.4/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.4/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.4/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.4/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.4/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.4/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.4/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.4/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.4/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4/conf/etc/supervisor.d/postfix.conf b/docker/php/8.4/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.4/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.4/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4/conf/etc/supervisor.d/ssh.conf b/docker/php/8.4/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.4/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.4/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.4/conf/etc/supervisor.d/syslog.conf b/docker/php/8.4/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.4/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.4/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5-alpine/conf/bin/service.d/ssh.sh b/docker/php/8.5-alpine/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.5-alpine/conf/bin/service.d/ssh.sh +++ b/docker/php/8.5-alpine/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.5-alpine/conf/etc/supervisor.d/cron.conf b/docker/php/8.5-alpine/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.5-alpine/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.5-alpine/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5-alpine/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.5-alpine/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.5-alpine/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.5-alpine/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5-alpine/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.5-alpine/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.5-alpine/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.5-alpine/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5-alpine/conf/etc/supervisor.d/postfix.conf b/docker/php/8.5-alpine/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.5-alpine/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.5-alpine/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5-alpine/conf/etc/supervisor.d/ssh.conf b/docker/php/8.5-alpine/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.5-alpine/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.5-alpine/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5-alpine/conf/etc/supervisor.d/syslog.conf b/docker/php/8.5-alpine/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.5-alpine/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.5-alpine/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5/conf/bin/service.d/ssh.sh b/docker/php/8.5/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.5/conf/bin/service.d/ssh.sh +++ b/docker/php/8.5/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.5/conf/etc/supervisor.d/cron.conf b/docker/php/8.5/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.5/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.5/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.5/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.5/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.5/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.5/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.5/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.5/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5/conf/etc/supervisor.d/postfix.conf b/docker/php/8.5/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.5/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.5/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5/conf/etc/supervisor.d/ssh.conf b/docker/php/8.5/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.5/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.5/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.5/conf/etc/supervisor.d/syslog.conf b/docker/php/8.5/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.5/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.5/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6-alpine/conf/bin/service.d/ssh.sh b/docker/php/8.6-alpine/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.6-alpine/conf/bin/service.d/ssh.sh +++ b/docker/php/8.6-alpine/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.6-alpine/conf/etc/supervisor.d/cron.conf b/docker/php/8.6-alpine/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.6-alpine/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.6-alpine/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6-alpine/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.6-alpine/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.6-alpine/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.6-alpine/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6-alpine/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.6-alpine/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.6-alpine/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.6-alpine/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6-alpine/conf/etc/supervisor.d/postfix.conf b/docker/php/8.6-alpine/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.6-alpine/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.6-alpine/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6-alpine/conf/etc/supervisor.d/ssh.conf b/docker/php/8.6-alpine/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.6-alpine/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.6-alpine/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6-alpine/conf/etc/supervisor.d/syslog.conf b/docker/php/8.6-alpine/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.6-alpine/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.6-alpine/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6/conf/bin/service.d/ssh.sh b/docker/php/8.6/conf/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/docker/php/8.6/conf/bin/service.d/ssh.sh +++ b/docker/php/8.6/conf/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.6/conf/etc/supervisor.d/cron.conf b/docker/php/8.6/conf/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/docker/php/8.6/conf/etc/supervisor.d/cron.conf +++ b/docker/php/8.6/conf/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6/conf/etc/supervisor.d/dnsmasq.conf b/docker/php/8.6/conf/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/docker/php/8.6/conf/etc/supervisor.d/dnsmasq.conf +++ b/docker/php/8.6/conf/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6/conf/etc/supervisor.d/php-fpm.conf b/docker/php/8.6/conf/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/docker/php/8.6/conf/etc/supervisor.d/php-fpm.conf +++ b/docker/php/8.6/conf/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6/conf/etc/supervisor.d/postfix.conf b/docker/php/8.6/conf/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/docker/php/8.6/conf/etc/supervisor.d/postfix.conf +++ b/docker/php/8.6/conf/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6/conf/etc/supervisor.d/ssh.conf b/docker/php/8.6/conf/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/docker/php/8.6/conf/etc/supervisor.d/ssh.conf +++ b/docker/php/8.6/conf/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docker/php/8.6/conf/etc/supervisor.d/syslog.conf b/docker/php/8.6/conf/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/docker/php/8.6/conf/etc/supervisor.d/syslog.conf +++ b/docker/php/8.6/conf/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/docs/README.md b/docs/README.md index 7a648dc70..68fbd5b93 100644 --- a/docs/README.md +++ b/docs/README.md @@ -33,7 +33,7 @@ Documentation for the `webdevops/*` Docker images. It describes the images as th ## Topics - [Environment variables](environment-variables.md): every setting, with defaults, including [uploads and long requests](environment-variables.md#uploads-and-long-requests) -- [Customization](customization.md): commands, scripts at start and build time, tools for your Dockerfile, services, cron jobs, healthcheck, configuration files, locales, the application user +- [Customization](customization.md): commands, scripts at start and build time, tools for your Dockerfile, services and their logs, cron jobs, healthcheck, configuration files, locales, the application user - PHP images: [PHP extensions per tag](images/php.md#php-extensions), [Debian or Alpine](images/php.md#debian-or-alpine), [production](images/php.md#production), [installing more extensions](images/php.md#installing-more-extensions), [mail](images/php.md#mail), [Xdebug with an IDE](images/php.md#xdebug-with-an-ide) - [Known issues](known-issues.md): options that do not work, workarounds, migration from older images - [Replacing discontinued images](discontinued-images.md): what to use instead of `php-official`, `nginx`, `apache`, the `alpine` tags of the base images, `storage`, `vsftp` and `ssh` diff --git a/docs/customization.md b/docs/customization.md index 34a00dfec..209775449 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -144,6 +144,23 @@ Before a service starts, its start script sources every `*.sh` file in `/opt/doc Options for each service are set with environment variables, see [Services](environment-variables.md#services). +### Logs + +The services write their logs to the container log, which `docker compose logs` shows: access logs and the messages of syslog to its stdout, error logs to its stderr. They write to `/docker.stdout` and `/docker.stderr`, which point to the stdout and stderr of the container, or to the files of `LOG_STDOUT` and `LOG_STDERR`, see [Container](environment-variables.md#container). + +| Service | Log | +| --- | --- | +| `nginx`, `apache` | Access log to `/docker.stdout`, error log to `/docker.stderr`, also of the virtual host for port 443 | +| `php-fpm` | Access log to `/docker.stdout`; its own messages, the errors of the PHP scripts and the [slow log](known-issues.md#slow-log-of-php-fpm) to `/docker.stderr` | +| `cron` | Its own messages to syslog. For the output of the jobs, see [Cron jobs](#cron-jobs). | +| `postfix`, `dnsmasq` | To syslog | +| `syslog` | syslog-ng writes the messages of syslog to `/docker.stdout`, with `[SYSLOG]` in front. It drops those of the facilities `auth` and `authpriv`, for example of `su`. What a service sends before syslog-ng listens, in about the first second after the start, is lost, for example the start messages of cron. | +| `ssh`, `blackfire-agent` | To their stderr | + +What the services print to their stdout and stderr, for example the output of their [hooks](#service-hooks) or of cron jobs in Alpine, supervisord writes to `/docker.stdout` and `/docker.stderr`. The messages of supervisord itself, for example `spawned: 'nginxd'`, always go to the container log; at the log level `debug` (`SERVICE_SUPERVISOR_OPTS=--loglevel=debug`) they also repeat what the services print. + +In `base` and `base-app`, enable `syslog` together with `cron`, `postfix` or `dnsmasq`, for example `RUN docker-service enable syslog cron`; without it, their messages are lost. + ## Cron jobs `docker-cronjob` adds a cron job for each argument. Lines use the system crontab format, including the user, and cron runs the job as that user: @@ -157,7 +174,12 @@ In the Debian- and Ubuntu-based images, `docker-cronjob` adds the lines to `/etc Cron in Debian and Ubuntu runs jobs with `PATH=/usr/bin:/bin`, which does not contain `/usr/local/bin`, so use absolute paths such as `/usr/local/bin/php`. Absolute paths work in Alpine too, whose `crond` passes on the `PATH` of the container. -In `base` and `base-app`, cron does not run by default; also run `docker-service enable cron`, see [Services](#services). +In `base` and `base-app`, cron does not run by default; also run `docker-service enable syslog cron`, see [Services](#services) and [Logs](#logs). + +The output of a job, stdout and stderr, goes to the container log, or to the files of `LOG_STDOUT` and `LOG_STDERR`: + +- In Alpine, BusyBox `crond` passes it on: stdout to the stdout of the container, stderr to its stderr. +- Cron in Debian and Ubuntu would mail it, and discard it where no mail server is installed. So `docker-cronjob` begins `/etc/cron.d/webdevops-docker` with `SHELL=/usr/local/bin/docker-cronjob-shell`: cron runs each job with this script, which runs the command with `/bin/sh` and sends both outputs to syslog, a message per line and per 1 KiB of a longer line. They reach the stdout of the container as `[SYSLOG] cron-job[]: `; the exit code stays that of the command. For a crontab file of your own, for example in `/etc/cron.d`, put the same `SHELL` line at its top; otherwise cron mails the output, see [Known issues](known-issues.md#output-of-cron-jobs-in-crontab-files-of-your-own). ### Time zone @@ -337,7 +359,7 @@ All images except `bootstrap` and `toolbox`. | `/opt/docker/etc/supervisor.conf` | Main configuration; includes `supervisor.d/*.conf` | | `/opt/docker/etc/supervisor.d/.conf` | One group per service with one program, for example the group `nginx` with the program `nginxd` | -Add your own program as a new file in `supervisor.d/`. In a running container, `supervisorctl` controls the services. Address a program as `:`, or all programs of a group as `:`; `supervisorctl restart nginx` fails with `no such process`. +Add your own program as a new file in `supervisor.d/`. Like the services of the image, it should write its output with `stdout_logfile=/docker.stdout` and `stderr_logfile=/docker.stderr`, each with `stdout_logfile_maxbytes=0` and `stderr_logfile_maxbytes=0`, see [Logs](#logs). In a running container, `supervisorctl` controls the services. Address a program as `:`, or all programs of a group as `:`; `supervisorctl restart nginx` fails with `no such process`. ```sh docker compose exec app supervisorctl status diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 78a1f8c3e..df5cca949 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -35,8 +35,8 @@ Images: `base`, `base-app`, `php-*`. | Variable | Default | Effect | | --- | --- | --- | | `CLI_SCRIPT` | not set | Command the `cli` entrypoint runs as `APPLICATION_USER`, in `base` as `root`. See [Customization](customization.md#commands). | -| `LOG_STDOUT` | container stdout | File that `/docker.stdout` points to. Nginx, Apache and PHP-FPM write their access logs there, syslog-ng the messages of the services, for example of cron and Postfix. | -| `LOG_STDERR` | container stderr | File that `/docker.stderr` points to. Nginx and Apache write their error logs there, PHP-FPM its own messages and the errors of the PHP scripts it runs. `php.error_log` gives the PHP errors of PHP-FPM and the PHP CLI a file of their own instead, in a directory that `application` may write to, for example `/app`. | +| `LOG_STDOUT` | container stdout | File that `/docker.stdout` points to. Nginx, Apache and PHP-FPM write their access logs there, syslog-ng the messages that the services send to syslog, for example of cron and Postfix, and in Debian and Ubuntu the output of the cron jobs of `docker-cronjob`. supervisord writes there what the services print to their stdout, for example in Alpine the output of cron jobs. The messages of supervisord itself, for example `spawned: 'nginxd'`, stay in the container log. See [Logs](customization.md#logs). | +| `LOG_STDERR` | container stderr | File that `/docker.stderr` points to. Nginx and Apache write their error logs there, PHP-FPM its own messages and the errors of the PHP scripts it runs, and supervisord what the services print to their stderr, for example the messages of sshd and of the Blackfire agent. `php.error_log` gives the PHP errors of PHP-FPM and the PHP CLI a file of their own instead, in a directory that `application` may write to, for example `/app`. | | `TZ` | not set (UTC) | Time zone of the container, for example `Europe/Berlin`. It applies to `date`, cron and the time stamps supervisord writes to the container log. PHP uses `PHP_DATE_TIMEZONE` instead, see [Time zone](customization.md#time-zone). | ## Web server @@ -183,7 +183,7 @@ Each service reads its options when it starts. A service only runs if it is enab | `SERVICE_SUPERVISOR_OPTS` | Extra arguments for `supervisord`, for example `--loglevel=debug`. | | `SERVICE_SYSLOG_OPTS` | Extra arguments for `syslog-ng`. | | `SERVICE_CRON_OPTS` | Extra arguments for `cron -f` (Debian/Ubuntu) or `crond -f` (Alpine). | -| `SERVICE_SSH_OPTS` | Extra arguments for `sshd -D`. | +| `SERVICE_SSH_OPTS` | Extra arguments for `sshd -D -e`. With `-e`, sshd logs to its stderr, see [Logs](customization.md#logs). | | `SERVICE_DNSMASQ_OPTS` | Extra arguments for `dnsmasq`. | | `SERVICE_DNSMASQ_USER` | User `dnsmasq` runs as. Default: `root`. | | `SERVICE_NGINX_OPTS` | Extra arguments for `nginx`, appended after `-g 'daemon off;'`. | diff --git a/docs/images/php.md b/docs/images/php.md index 98522f5b4..c67f813b7 100644 --- a/docs/images/php.md +++ b/docs/images/php.md @@ -128,7 +128,7 @@ Every PHP version comes as a Debian tag (`8.5`) and an Alpine tag (`8.5-alpine`) | [Build tools for extensions](#installing-more-extensions) | included | installed by `docker-php-ext-install`; for PIE install `$PHPIZE_DEPS` | | [Locales](../customization.md#locales) | several hundred, for example `de_DE.utf8` | none | | [Installing packages](../customization.md#tools-for-your-dockerfile) | `apt-install`, from the Debian components `main`, `contrib` and `non-free` | `apk-install` | -| [`docker-cronjob`](../customization.md#cron-jobs) | adds the lines to `/etc/cron.d/webdevops-docker`; jobs run with `PATH=/usr/bin:/bin` | adds each line without its user to `/etc/crontabs/`; jobs run with the `PATH` of the container | +| [`docker-cronjob`](../customization.md#cron-jobs) | adds the lines to `/etc/cron.d/webdevops-docker`; jobs run with `PATH=/usr/bin:/bin`; their output goes through syslog to the stdout of the container | adds each line without its user to `/etc/crontabs/`; jobs run with the `PATH` of the container; their output goes to the stdout and stderr of the container | | [`docker-image-cleanup`](../customization.md#tools-for-your-dockerfile) | works | works | | [Apache index files](../environment-variables.md#web-server) in `php-apache` | `index.html`, `index.cgi`, `index.pl`, `index.php`, `index.xhtml`, `index.htm` come before `WEB_DOCUMENT_INDEX` | `index.html` comes before `WEB_DOCUMENT_INDEX` | | [`mail()` without Postfix](#mail) | fails: there is no `sendmail` command | fails: BusyBox `sendmail` finds no mail server | diff --git a/docs/known-issues.md b/docs/known-issues.md index 90d4e8d5c..386d89642 100644 --- a/docs/known-issues.md +++ b/docs/known-issues.md @@ -22,6 +22,28 @@ These options and tools are part of the images but do not work, or work only in - **Images:** `php-*` with the Debian tag `8.6`. - **Instead:** Write the repository to a file in `/etc/apt/sources.list.d/`, for example `RUN echo "deb http://deb.debian.org/debian trixie-backports main" > /etc/apt/sources.list.d/backports.list`. +### Output of cron jobs in crontab files of your own + +- **Effect:** Cron in Debian and Ubuntu mails the output of a job. Where no mail server runs, it discards it and logs `(CRON) info (No MTA installed, discarding output)`; where Postfix runs, as in the `-dev` images, the output lands in the mailbox of the user, for example `/var/mail/application`. Only the jobs that `docker-cronjob` adds send their output to the container log, see [Cron jobs](customization.md#cron-jobs). +- **Images:** the Debian and Ubuntu images: `php-*` without `-alpine`, `base`, `base-app`. +- **Instead:** Add the jobs with `docker-cronjob`, or put `SHELL=/usr/local/bin/docker-cronjob-shell` at the top of your crontab file in `/etc/cron.d`. + +### Slow log of PHP-FPM + +- **Effect:** With `fpm.pool.request_slowlog_timeout`, for example `5s`, PHP-FPM logs that a request is slow, but not where it is: Docker does not give a container the capability `SYS_PTRACE`, which PHP-FPM needs for the backtrace. The log shows `ERROR: failed to ptrace(ATTACH) child …: Operation not permitted (1)` instead. +- **Images:** `php-*`. +- **Instead:** Add the capability to the container: + + ```yaml + services: + app: + image: webdevops/php-nginx:8.5 + cap_add: + - SYS_PTRACE + environment: + fpm.pool.request_slowlog_timeout: 5s + ``` + ### Composer 1 on PHP 8.4 to 8.6 - **Effect:** With `COMPOSER_VERSION=1`, every Composer run prints deprecation notices. From PHP 8.5 on, Composer 1 also cannot download packages: commands such as `composer require` stop with `Uncaught TypeError: stream_context_create(): Argument #1 ($options) must be an array with valid callbacks as values`. diff --git a/provisioning/apache/general/etc/supervisor.d/apache.conf b/provisioning/apache/general/etc/supervisor.d/apache.conf index 12a6f86f7..3d09bff7d 100644 --- a/provisioning/apache/general/etc/supervisor.d/apache.conf +++ b/provisioning/apache/general/etc/supervisor.d/apache.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/bin/service.d/ssh.sh b/provisioning/base/general/bin/service.d/ssh.sh index f01e87ab3..5e2a0036d 100644 --- a/provisioning/base/general/bin/service.d/ssh.sh +++ b/provisioning/base/general/bin/service.d/ssh.sh @@ -7,4 +7,6 @@ source /opt/docker/bin/config.sh includeScriptDir "/opt/docker/bin/service.d/ssh.d/" -exec /usr/sbin/sshd -D $SERVICE_SSH_OPTS +# -e: sshd logs to its stderr, which supervisord writes to the container log, instead of to syslog, which does not run in +# every image and where syslog-ng drops the facility auth of sshd +exec /usr/sbin/sshd -D -e $SERVICE_SSH_OPTS diff --git a/provisioning/base/general/bin/usr-bin/docker-cronjob b/provisioning/base/general/bin/usr-bin/docker-cronjob index ca4aacb1b..225ca42f0 100644 --- a/provisioning/base/general/bin/usr-bin/docker-cronjob +++ b/provisioning/base/general/bin/usr-bin/docker-cronjob @@ -40,6 +40,12 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker +# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which +# sends their output to syslog-ng and with it to the container log +if [[ ! -s /etc/cron.d/webdevops-docker ]]; then + echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker +fi + for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/provisioning/base/general/bin/usr-bin/docker-cronjob-shell b/provisioning/base/general/bin/usr-bin/docker-cronjob-shell new file mode 100644 index 000000000..159ff749c --- /dev/null +++ b/provisioning/base/general/bin/usr-bin/docker-cronjob-shell @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in +# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu +# mails the output of a job, and discards it where no mail server is installed. This script runs the command with +# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the +# container log. The exit code stays that of the command. + +# the command runs with the shell that cron would use +export SHELL=/bin/sh + +# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of +# syslog-ng if supervisord starts it +if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then + for _ in {1..20}; do + [[ -S /dev/log ]] && break + sleep 0.5 + done +fi + +# without syslog-ng, the output goes to cron as before +if [[ ! -S /dev/log ]]; then + exec /bin/sh "$@" +fi + +# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should +# logger end early, cat reads the rest, so the command does not end on a broken pipe +/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } +exit "${PIPESTATUS[0]}" diff --git a/provisioning/base/general/etc/supervisor.d/cron.conf b/provisioning/base/general/etc/supervisor.d/cron.conf index ef0a71678..d3a979bdc 100644 --- a/provisioning/base/general/etc/supervisor.d/cron.conf +++ b/provisioning/base/general/etc/supervisor.d/cron.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/dnsmasq.conf b/provisioning/base/general/etc/supervisor.d/dnsmasq.conf index 9832ffca7..56969c944 100644 --- a/provisioning/base/general/etc/supervisor.d/dnsmasq.conf +++ b/provisioning/base/general/etc/supervisor.d/dnsmasq.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/postfix.conf b/provisioning/base/general/etc/supervisor.d/postfix.conf index 9e26baaa2..33a60cac8 100644 --- a/provisioning/base/general/etc/supervisor.d/postfix.conf +++ b/provisioning/base/general/etc/supervisor.d/postfix.conf @@ -11,7 +11,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/ssh.conf b/provisioning/base/general/etc/supervisor.d/ssh.conf index 0ecd798d6..74f376a18 100644 --- a/provisioning/base/general/etc/supervisor.d/ssh.conf +++ b/provisioning/base/general/etc/supervisor.d/ssh.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs=0 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/base/general/etc/supervisor.d/syslog.conf b/provisioning/base/general/etc/supervisor.d/syslog.conf index 20d1e238c..6c706c2bc 100644 --- a/provisioning/base/general/etc/supervisor.d/syslog.conf +++ b/provisioning/base/general/etc/supervisor.d/syslog.conf @@ -7,7 +7,8 @@ command = /opt/docker/bin/service.d/syslog-ng.sh process_name=%(program_name)s autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/nginx/alpine/etc/nginx/nginx.conf b/provisioning/nginx/alpine/etc/nginx/nginx.conf index b9cb4ebc4..981590f32 100644 --- a/provisioning/nginx/alpine/etc/nginx/nginx.conf +++ b/provisioning/nginx/alpine/etc/nginx/nginx.conf @@ -4,7 +4,7 @@ user nginx; worker_processes auto; -error_log /docker.stdout; +error_log /docker.stderr; pid /run/nginx.pid; events { diff --git a/provisioning/nginx/general/etc/supervisor.d/nginx.conf b/provisioning/nginx/general/etc/supervisor.d/nginx.conf index 657bf499b..afcdbf5aa 100644 --- a/provisioning/nginx/general/etc/supervisor.d/nginx.conf +++ b/provisioning/nginx/general/etc/supervisor.d/nginx.conf @@ -8,7 +8,8 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/php-dev/general/etc/supervisor.d/blackfire-agent.conf b/provisioning/php-dev/general/etc/supervisor.d/blackfire-agent.conf index 008644ac9..e7a575e64 100644 --- a/provisioning/php-dev/general/etc/supervisor.d/blackfire-agent.conf +++ b/provisioning/php-dev/general/etc/supervisor.d/blackfire-agent.conf @@ -10,7 +10,8 @@ process_name=%(program_name)s startsecs = 5 autostart = false autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 diff --git a/provisioning/php/general/etc/supervisor.d/php-fpm.conf b/provisioning/php/general/etc/supervisor.d/php-fpm.conf index 5781f5b0a..1983c337c 100644 --- a/provisioning/php/general/etc/supervisor.d/php-fpm.conf +++ b/provisioning/php/general/etc/supervisor.d/php-fpm.conf @@ -8,8 +8,9 @@ process_name=%(program_name)s startsecs = 0 autostart = true autorestart = true -stdout_logfile=/dev/stdout +; the container log, or the files of LOG_STDOUT and LOG_STDERR +stdout_logfile=/docker.stdout stdout_logfile_maxbytes=0 -stderr_logfile=/dev/stderr +stderr_logfile=/docker.stderr stderr_logfile_maxbytes=0 From a6431924bd5fb7df70e40e6fd9bc7c71a418c10e Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Mon, 23 Nov 2026 08:14:11 +0000 Subject: [PATCH 2/3] Move the output of cron jobs to a pull request of its own The output of the cron jobs of docker-cronjob changes how cron behaves in Debian and Ubuntu (no mail), so it moves to #667. A new image test checks that without LOG_STDOUT and LOG_STDERR the output of the services stays in the container log. --- .../Checks/ContainerEnvironmentChecks.php | 48 ++++++++----------- .../Hooks/entrypoint.d/70-image-test-cron.sh | 8 ---- .../conf/bin/usr-bin/docker-cronjob | 6 --- .../conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../conf/bin/usr-bin/docker-cronjob | 6 --- .../conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../php/8.2/conf/bin/usr-bin/docker-cronjob | 6 --- .../8.2/conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../conf/bin/usr-bin/docker-cronjob | 6 --- .../conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../php/8.3/conf/bin/usr-bin/docker-cronjob | 6 --- .../8.3/conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../conf/bin/usr-bin/docker-cronjob | 6 --- .../conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../php/8.4/conf/bin/usr-bin/docker-cronjob | 6 --- .../8.4/conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../conf/bin/usr-bin/docker-cronjob | 6 --- .../conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../php/8.5/conf/bin/usr-bin/docker-cronjob | 6 --- .../8.5/conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../conf/bin/usr-bin/docker-cronjob | 6 --- .../conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- .../php/8.6/conf/bin/usr-bin/docker-cronjob | 6 --- .../8.6/conf/bin/usr-bin/docker-cronjob-shell | 28 ----------- docs/customization.md | 7 +-- docs/environment-variables.md | 2 +- docs/images/php.md | 2 +- docs/known-issues.md | 6 --- .../base/general/bin/usr-bin/docker-cronjob | 6 --- .../general/bin/usr-bin/docker-cronjob-shell | 28 ----------- 30 files changed, 22 insertions(+), 459 deletions(-) delete mode 100644 docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell delete mode 100644 provisioning/base/general/bin/usr-bin/docker-cronjob-shell diff --git a/ci/image-tests/Checks/ContainerEnvironmentChecks.php b/ci/image-tests/Checks/ContainerEnvironmentChecks.php index 7109d6544..41d9c35d1 100644 --- a/ci/image-tests/Checks/ContainerEnvironmentChecks.php +++ b/ci/image-tests/Checks/ContainerEnvironmentChecks.php @@ -98,35 +98,6 @@ public function testSyslogMessagesReachTheFileFromTheEnvironment(): void }); } - /** - * The output of a cron job that docker-cronjob added, from Hooks/, reaches the files of LOG_STDOUT and LOG_STDERR. - * Cron in Debian and Ubuntu would mail it, or discard it without a mail server: docker-cronjob-shell passes both - * lines to syslog-ng, which writes them to the file of LOG_STDOUT. BusyBox crond on Alpine passes on its own stdout - * and stderr, which supervisord writes to the two files. Only in the images that start cron. - */ - public function testCronJobOutputReachesTheFilesFromTheEnvironment(): void - { - if (!in_array('cron', self::services(), true)) { - self::markTestSkipped('The image does not start cron.'); - } - - $container = $this->environmentContainer(); - // the job writes the lines in upper case, so they differ from its command, which cron logs - [$output, $error] = ['IMAGE-TEST-CRON-OUTPUT', 'IMAGE-TEST-CRON-ERROR']; - // cron runs the job at the start of a minute - $this->waitFor(function () use ($container, $output, $error): void { - $stdout = $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDOUT'], $container); - $stderr = $this->stdout('cat ' . static::ENVIRONMENT['LOG_STDERR'], $container); - if (self::image()->isAlpine()) { - self::assertMatchesRegularExpression('/^' . $output . '$/m', $stdout); - self::assertMatchesRegularExpression('/^' . $error . '$/m', $stderr); - } else { - self::assertMatchesRegularExpression('/ cron-job\[\d+\]: ' . $output . '$/m', $stdout); - self::assertMatchesRegularExpression('/ cron-job\[\d+\]: ' . $error . '$/m', $stdout); - } - }, 25, 3); - } - /** * What a service writes to its stdout and stderr reaches the files of LOG_STDOUT and LOG_STDERR: supervisord writes * it there. The hook of syslog-ng from Hooks/ writes a line to each. The environment container starts syslog-ng @@ -146,6 +117,25 @@ public function testServiceOutputReachesTheFilesFromTheEnvironment(): void }); } + /** + * Without LOG_STDOUT and LOG_STDERR, what a service writes to its stdout and stderr stays in the container log, as + * before supervisord wrote it to /docker.stdout and /docker.stderr: the hook of syslog-ng from Hooks/ writes a line + * to each. In a container of its own, which starts syslog-ng where the image does not. + */ + public function testServiceOutputReachesTheContainerLogWithoutTheEnvironment(): void + { + $container = $this->startTestContainer('service-output'); + if (!in_array('syslog', self::services(), true)) { + $this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container); + } + + $this->eventually(function () use ($container): void { + [$stdout, $stderr] = $container->logStreams(); + self::assertStringContainsString('image-test: the hook of syslog-ng on stdout', $stdout); + self::assertStringContainsString('image-test: the hook of syslog-ng on stderr', $stderr); + }); + } + /** * /docker.stdout and /docker.stderr, where the services of the image write their logs, point to the files of * LOG_STDOUT and LOG_STDERR. diff --git a/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh b/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh index 59ff7c6c9..808cafb26 100644 --- a/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh +++ b/ci/image-tests/Hooks/entrypoint.d/70-image-test-cron.sh @@ -1,8 +1,6 @@ # Image tests: with IMAGE_TEST_CRON set to hours, e.g. "9,10", adds a cron job for these hours before cron starts, which # marks that it ran, see ContainerEnvironmentChecks. The tests set the current and the next hour in Berlin, worked out # outside the image, so cron runs the job only if it uses the time zone of TZ. -# It also adds a job with docker-cronjob that writes a line to stdout and one to stderr every minute, in upper case, so -# that the lines differ from the command, which cron logs. if [[ -n "${IMAGE_TEST_CRON:-}" ]]; then if [[ -d /etc/crontabs ]]; then # BusyBox crond on Alpine @@ -11,10 +9,4 @@ if [[ -n "${IMAGE_TEST_CRON:-}" ]]; then echo "* ${IMAGE_TEST_CRON} * * * root echo ran > /tmp/image-tests/cron-job" > /etc/cron.d/image-test chmod 644 /etc/cron.d/image-test fi - - # where docker-cronjob fails, as on Alpine before it wrote to /etc/crontabs, the container starts all the same; the - # test of the output fails then - if id application > /dev/null 2>&1; then - docker-cronjob '* * * * * application echo image-test-cron-output | tr a-z A-Z; echo image-test-cron-error | tr a-z A-Z >&2' || true - fi fi diff --git a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob +++ b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell b/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/base/ubuntu-22.04/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.2-alpine/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.2/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.3-alpine/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.3/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.4-alpine/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.4/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.5-alpine/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.5/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.6-alpine/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob +++ b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell b/docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/docker/php/8.6/conf/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" diff --git a/docs/customization.md b/docs/customization.md index 209775449..5159f2782 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -152,7 +152,7 @@ The services write their logs to the container log, which `docker compose logs` | --- | --- | | `nginx`, `apache` | Access log to `/docker.stdout`, error log to `/docker.stderr`, also of the virtual host for port 443 | | `php-fpm` | Access log to `/docker.stdout`; its own messages, the errors of the PHP scripts and the [slow log](known-issues.md#slow-log-of-php-fpm) to `/docker.stderr` | -| `cron` | Its own messages to syslog. For the output of the jobs, see [Cron jobs](#cron-jobs). | +| `cron` | Its own messages to syslog | | `postfix`, `dnsmasq` | To syslog | | `syslog` | syslog-ng writes the messages of syslog to `/docker.stdout`, with `[SYSLOG]` in front. It drops those of the facilities `auth` and `authpriv`, for example of `su`. What a service sends before syslog-ng listens, in about the first second after the start, is lost, for example the start messages of cron. | | `ssh`, `blackfire-agent` | To their stderr | @@ -176,11 +176,6 @@ Cron in Debian and Ubuntu runs jobs with `PATH=/usr/bin:/bin`, which does not co In `base` and `base-app`, cron does not run by default; also run `docker-service enable syslog cron`, see [Services](#services) and [Logs](#logs). -The output of a job, stdout and stderr, goes to the container log, or to the files of `LOG_STDOUT` and `LOG_STDERR`: - -- In Alpine, BusyBox `crond` passes it on: stdout to the stdout of the container, stderr to its stderr. -- Cron in Debian and Ubuntu would mail it, and discard it where no mail server is installed. So `docker-cronjob` begins `/etc/cron.d/webdevops-docker` with `SHELL=/usr/local/bin/docker-cronjob-shell`: cron runs each job with this script, which runs the command with `/bin/sh` and sends both outputs to syslog, a message per line and per 1 KiB of a longer line. They reach the stdout of the container as `[SYSLOG] cron-job[]: `; the exit code stays that of the command. For a crontab file of your own, for example in `/etc/cron.d`, put the same `SHELL` line at its top; otherwise cron mails the output, see [Known issues](known-issues.md#output-of-cron-jobs-in-crontab-files-of-your-own). - ### Time zone Cron uses the container's time zone, which is UTC. `PHP_DATE_TIMEZONE` only changes PHP's time zone, not when cron runs a job. To run jobs in local time, set `TZ`. It also changes the output of `date` and the time stamps supervisord writes to the container log. PHP keeps `PHP_DATE_TIMEZONE`, so set both: diff --git a/docs/environment-variables.md b/docs/environment-variables.md index df5cca949..8d2154816 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -35,7 +35,7 @@ Images: `base`, `base-app`, `php-*`. | Variable | Default | Effect | | --- | --- | --- | | `CLI_SCRIPT` | not set | Command the `cli` entrypoint runs as `APPLICATION_USER`, in `base` as `root`. See [Customization](customization.md#commands). | -| `LOG_STDOUT` | container stdout | File that `/docker.stdout` points to. Nginx, Apache and PHP-FPM write their access logs there, syslog-ng the messages that the services send to syslog, for example of cron and Postfix, and in Debian and Ubuntu the output of the cron jobs of `docker-cronjob`. supervisord writes there what the services print to their stdout, for example in Alpine the output of cron jobs. The messages of supervisord itself, for example `spawned: 'nginxd'`, stay in the container log. See [Logs](customization.md#logs). | +| `LOG_STDOUT` | container stdout | File that `/docker.stdout` points to. Nginx, Apache and PHP-FPM write their access logs there, syslog-ng the messages that the services send to syslog, for example of cron and Postfix. supervisord writes there what the services print to their stdout, for example in Alpine the output of cron jobs. The messages of supervisord itself, for example `spawned: 'nginxd'`, stay in the container log. See [Logs](customization.md#logs). | | `LOG_STDERR` | container stderr | File that `/docker.stderr` points to. Nginx and Apache write their error logs there, PHP-FPM its own messages and the errors of the PHP scripts it runs, and supervisord what the services print to their stderr, for example the messages of sshd and of the Blackfire agent. `php.error_log` gives the PHP errors of PHP-FPM and the PHP CLI a file of their own instead, in a directory that `application` may write to, for example `/app`. | | `TZ` | not set (UTC) | Time zone of the container, for example `Europe/Berlin`. It applies to `date`, cron and the time stamps supervisord writes to the container log. PHP uses `PHP_DATE_TIMEZONE` instead, see [Time zone](customization.md#time-zone). | diff --git a/docs/images/php.md b/docs/images/php.md index c67f813b7..98522f5b4 100644 --- a/docs/images/php.md +++ b/docs/images/php.md @@ -128,7 +128,7 @@ Every PHP version comes as a Debian tag (`8.5`) and an Alpine tag (`8.5-alpine`) | [Build tools for extensions](#installing-more-extensions) | included | installed by `docker-php-ext-install`; for PIE install `$PHPIZE_DEPS` | | [Locales](../customization.md#locales) | several hundred, for example `de_DE.utf8` | none | | [Installing packages](../customization.md#tools-for-your-dockerfile) | `apt-install`, from the Debian components `main`, `contrib` and `non-free` | `apk-install` | -| [`docker-cronjob`](../customization.md#cron-jobs) | adds the lines to `/etc/cron.d/webdevops-docker`; jobs run with `PATH=/usr/bin:/bin`; their output goes through syslog to the stdout of the container | adds each line without its user to `/etc/crontabs/`; jobs run with the `PATH` of the container; their output goes to the stdout and stderr of the container | +| [`docker-cronjob`](../customization.md#cron-jobs) | adds the lines to `/etc/cron.d/webdevops-docker`; jobs run with `PATH=/usr/bin:/bin` | adds each line without its user to `/etc/crontabs/`; jobs run with the `PATH` of the container | | [`docker-image-cleanup`](../customization.md#tools-for-your-dockerfile) | works | works | | [Apache index files](../environment-variables.md#web-server) in `php-apache` | `index.html`, `index.cgi`, `index.pl`, `index.php`, `index.xhtml`, `index.htm` come before `WEB_DOCUMENT_INDEX` | `index.html` comes before `WEB_DOCUMENT_INDEX` | | [`mail()` without Postfix](#mail) | fails: there is no `sendmail` command | fails: BusyBox `sendmail` finds no mail server | diff --git a/docs/known-issues.md b/docs/known-issues.md index 386d89642..3b1569b09 100644 --- a/docs/known-issues.md +++ b/docs/known-issues.md @@ -22,12 +22,6 @@ These options and tools are part of the images but do not work, or work only in - **Images:** `php-*` with the Debian tag `8.6`. - **Instead:** Write the repository to a file in `/etc/apt/sources.list.d/`, for example `RUN echo "deb http://deb.debian.org/debian trixie-backports main" > /etc/apt/sources.list.d/backports.list`. -### Output of cron jobs in crontab files of your own - -- **Effect:** Cron in Debian and Ubuntu mails the output of a job. Where no mail server runs, it discards it and logs `(CRON) info (No MTA installed, discarding output)`; where Postfix runs, as in the `-dev` images, the output lands in the mailbox of the user, for example `/var/mail/application`. Only the jobs that `docker-cronjob` adds send their output to the container log, see [Cron jobs](customization.md#cron-jobs). -- **Images:** the Debian and Ubuntu images: `php-*` without `-alpine`, `base`, `base-app`. -- **Instead:** Add the jobs with `docker-cronjob`, or put `SHELL=/usr/local/bin/docker-cronjob-shell` at the top of your crontab file in `/etc/cron.d`. - ### Slow log of PHP-FPM - **Effect:** With `fpm.pool.request_slowlog_timeout`, for example `5s`, PHP-FPM logs that a request is slow, but not where it is: Docker does not give a container the capability `SYS_PTRACE`, which PHP-FPM needs for the backtrace. The log shows `ERROR: failed to ptrace(ATTACH) child …: Operation not permitted (1)` instead. diff --git a/provisioning/base/general/bin/usr-bin/docker-cronjob b/provisioning/base/general/bin/usr-bin/docker-cronjob index 225ca42f0..ca4aacb1b 100644 --- a/provisioning/base/general/bin/usr-bin/docker-cronjob +++ b/provisioning/base/general/bin/usr-bin/docker-cronjob @@ -40,12 +40,6 @@ fi touch /etc/cron.d/webdevops-docker chmod 0644 /etc/cron.d/webdevops-docker -# Cron in Debian and Ubuntu mails the output of a job: the jobs of this file run with docker-cronjob-shell instead, which -# sends their output to syslog-ng and with it to the container log -if [[ ! -s /etc/cron.d/webdevops-docker ]]; then - echo 'SHELL=/usr/local/bin/docker-cronjob-shell' >> /etc/cron.d/webdevops-docker -fi - for CRONJOB_LINES in "$@"; do echo "$CRONJOB_LINES" >> /etc/cron.d/webdevops-docker done diff --git a/provisioning/base/general/bin/usr-bin/docker-cronjob-shell b/provisioning/base/general/bin/usr-bin/docker-cronjob-shell deleted file mode 100644 index 159ff749c..000000000 --- a/provisioning/base/general/bin/usr-bin/docker-cronjob-shell +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# The shell of the cron jobs that docker-cronjob adds in Debian and Ubuntu: docker-cronjob sets SHELL to this script in -# /etc/cron.d/webdevops-docker, so cron runs each job as "docker-cronjob-shell -c ". Cron in Debian and Ubuntu -# mails the output of a job, and discards it where no mail server is installed. This script runs the command with -# /bin/sh, as cron would, and sends its output, stdout and stderr, to syslog, from where syslog-ng writes it to the -# container log. The exit code stays that of the command. - -# the command runs with the shell that cron would use -export SHELL=/bin/sh - -# Cron runs @reboot jobs as soon as it starts, at the same time as syslog-ng: wait up to 10 seconds for the socket of -# syslog-ng if supervisord starts it -if [[ ! -S /dev/log ]] && grep -q '^autostart *= *true' /opt/docker/etc/supervisor.d/syslog.conf 2> /dev/null; then - for _ in {1..20}; do - [[ -S /dev/log ]] && break - sleep 0.5 - done -fi - -# without syslog-ng, the output goes to cron as before -if [[ ! -S /dev/log ]]; then - exec /bin/sh "$@" -fi - -# each line, and each KiB of a longer line, as a message of its own, tagged with the process id of the job; should -# logger end early, cat reads the rest, so the command does not end on a broken pipe -/bin/sh "$@" 2>&1 | { logger -t "cron-job[$$]" -p cron.info || cat > /dev/null; } -exit "${PIPESTATUS[0]}" From fc7960b23e2163caa8b3eb3a886dcd9d9a3c7a53 Mon Sep 17 00:00:00 2001 From: Matthias Vogel Date: Mon, 23 Nov 2026 08:23:46 +0000 Subject: [PATCH 3/3] [TASK] Image tests: one constant for starting syslog-ng --- ci/image-tests/Checks/ContainerEnvironmentChecks.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ci/image-tests/Checks/ContainerEnvironmentChecks.php b/ci/image-tests/Checks/ContainerEnvironmentChecks.php index 41d9c35d1..8588f64c5 100644 --- a/ci/image-tests/Checks/ContainerEnvironmentChecks.php +++ b/ci/image-tests/Checks/ContainerEnvironmentChecks.php @@ -25,6 +25,9 @@ */ trait ContainerEnvironmentChecks { + /** Starts syslog-ng in a container of an image that does not start it */ + private const string START_SYSLOG = 'docker-service enable syslog && docker-service start syslog'; + /** * TZ=Europe/Berlin: date shows the time zone, and supervisord writes local time to the container log. */ @@ -89,7 +92,7 @@ public function testSyslogMessagesReachTheFileFromTheEnvironment(): void { $container = $this->environmentContainer(); if (!in_array('syslog', self::services(), true)) { - $this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container); + $this->assertCommandSucceeds(self::START_SYSLOG, $container); } $this->eventually(function () use ($container): void { @@ -108,7 +111,7 @@ public function testServiceOutputReachesTheFilesFromTheEnvironment(): void { $container = $this->environmentContainer(); if (!in_array('syslog', self::services(), true)) { - $this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container); + $this->assertCommandSucceeds(self::START_SYSLOG, $container); } $this->eventually(function () use ($container): void { @@ -126,7 +129,7 @@ public function testServiceOutputReachesTheContainerLogWithoutTheEnvironment(): { $container = $this->startTestContainer('service-output'); if (!in_array('syslog', self::services(), true)) { - $this->assertCommandSucceeds('docker-service enable syslog && docker-service start syslog', $container); + $this->assertCommandSucceeds(self::START_SYSLOG, $container); } $this->eventually(function () use ($container): void {