Repository navigation
Conversation
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/<user>.
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.
This was referenced Nov 21, 2026
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.
…ainer-log # Conflicts: # docker/base/ubuntu-22.04/conf/bin/service.d/ssh.sh # docker/base/ubuntu-22.04/conf/etc/supervisor.d/cron.conf # docker/base/ubuntu-22.04/conf/etc/supervisor.d/dnsmasq.conf # docker/base/ubuntu-22.04/conf/etc/supervisor.d/postfix.conf # docker/base/ubuntu-22.04/conf/etc/supervisor.d/ssh.conf # docker/base/ubuntu-22.04/conf/etc/supervisor.d/syslog.conf # docs/customization.md # docs/environment-variables.md
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
#656 sent the logs of PHP-FPM to
/docker.stdoutand/docker.stderr. An audit of all the other logs of the images, below, found logs that did not reach the container log (docker logs), or not the files ofLOG_STDOUTandLOG_STDERRwhere those are set:auth, which syslog-ng drops (not facility(auth, authpriv)). A failed login showed up nowhere in the-devimages.LOG_STDOUTandLOG_STDERR, because supervisord wrote it to/dev/stdoutand/dev/stderr: the output of cron jobs in Alpine, the messages of the Blackfire agent, the output of the start scripts and their hooks, warnings of syslog-ng, start messages of Postfix in Alpine and of PHP-FPM before it opens its log.worker process 89 exited on signal 9) went to/docker.stdout, so to the stdout of the container or the file ofLOG_STDOUT: the image's ownnginx.conffor Alpine haserror_log /docker.stdout.No upstream issue asks for this directly.
The audit also found that cron in Debian and Ubuntu mails or discards the output of its jobs. Fixing that changes how cron behaves (no mail any more), so it is a pull request of its own: #667. This pull request leaves cron as it is.
Audit
Running containers of the published images with the change of #656 on top (its
20-setup-php-fpm-pool.shrun in the image):php,php-dev,php-nginx,php-nginx-dev,php-apache,php-apache-dev, each8.5and8.5-alpine, andbaseandbase-appubuntu-22.04withcron,syslog,postfix,sshanddnsmasqenabled (php-devwithdnsmasqtoo). In each container: a request straight to PHP-FPM and over http and https through the web server, each callingerror_log(), also withXDEBUG_TRIGGER=1; a 404; a request slower thanfpm.pool.request_slowlog_timeout=1s;error_log()and a warning in the PHP CLI; a mail withsendmail; a failedsshlogin;loggerwith the facilitiesuserandauth; a cron job ofapplicationthat writes to stdout and stderr and runs PHP with a warning. Thenfind / -xdev -newer <marker> -type fafter a cron run, anddocker logswith stdout and stderr apart. The-devimages ran a second time withLOG_STDOUTandLOG_STDERR,php-deva third time withPHP_DEBUGGER=blackfire(with the start script of the agent from master)."Container log" means
docker logs, or the files ofLOG_STDOUTandLOG_STDERRwhere they are set.spawned: 'nginxd',exited: …)nodaemon,--logfile /dev/null), also withLOG_STDOUTLOG_STDOUT: stays indocker logs)docker logsshows it; the docs ofTZand of the healthcheck rely on it. Documented.-> Executing …,Setting php-fpm user to application), warnings of syslog-ng, PHP-FPM'sFailed implicitly binding to ::,postfix/postlog: starting the Postfix mail system(Alpine), the Blackfire agent, the output of cron jobs on Alpinestdout_logfile=/dev/stdout,stderr_logfile=/dev/stderrLOG_*; no with them: indocker logs, not in the filessupervisor.d/*.confof all services:/docker.stdoutand/docker.stderr, so they followLOG_STDOUTandLOG_STDERR/dev/logand its own (internal()) topipe("/docker.stdout")(file()withLOG_STDOUT), with[SYSLOG]authandauthprivare dropped (filterf_filter); what a service sends before syslog-ng listens (about the first second) is lostCMD,END,(CRON) INFO)base,base-apponly ifsyslogis enabled too);(CRON) INFO (pidfile fd = 3)and(Running @reboot jobs)missing in some runs (race); the PAM session lines areauthprivand droppedsyslogwithcroninbaseandbase-appcrond): its own messages/usr/sbin/sendmail: inphp,php-nginx,php-apache(no MTA) discarded,(CRON) info (No MTA installed, discarding output); in the-devimages and inbase/base-appwith Postfix delivered locally to/var/mail/applicationor/var/mail/root, which growcrondpasses on its stdout and stderr to the job, i.e. supervisord's pipesLOG_*; no with them (indocker logs)supervisor.dchange abovedocker exec,docker compose run)log_errors=1, noerror_log)php.error_loggives them a filemail); Debian: warnings ofnewaliases/postsuper, Alpine:postfix/postlogstart lines on stderrbase/base-appwithoutsyslog: lostsyslogwithpostfixinbaseandbase-app. Bounces of undeliverable mail go to/var/mail/root: mail, not a log, left.authauthsshd -D -e: sshd logs to its stderr, so to the container stderr orLOG_STDERR, also without syslog-ngdaemon)sysloginbase--log-facility=-would make dnsmasq exit whenSERVICE_DNSMASQ_OPTSsets--log-facilitytoo (illegal repeated flag); docs: enablesyslogwithdnsmasqinbaseandbase-app/docker.stdout(vhost.common.d/10-log.conf,access_logofnginx.conf)/docker.stderr(warn,-dev:info)worker process … exited on signal 9)/docker.stderr(notice); Alpine:error_log /docker.stdoutin the image's ownnginx.confLOG_STDOUTnginx.conf:/docker.stderr/var/log/nginx/var/lib/nginx/logs; nothing written there in the runs/docker.stdout:CustomLogofconf.d/10-log.confand the distribution's (other_vhosts_access.logon Debian,access.loginhttpd.confon Alpine), which the build points to/docker.stdouttoo/docker.stderr(warn,-dev:info);vhost.ssl.confsets no log of its own/docker.stderr,/docker.stdout(#656)/docker.stderr, through the master (#656)slowlog = /docker.stderr, off by defaultSYS_PTRACE, otherwiseERROR: failed to ptrace(ATTACH) child …: Operation not permittedcap_add: SYS_PTRACExdebug.log; its messages (Could not connect to debugging client) go to PHP's error log--log-filedefaultstderrLOG_*; with them indocker logssupervisor.dchange above[Error] APM: … Cannot connect to the agent)docker-healthcheck/proc/1/fd/2LOG_STDERR: stays indocker logs)/var/logchanged in any run (Alpine has emptyauth.log,error.log,kern.log,mail.logfrom the build;apk.log/dpkg logs only change with packages);/var/mail/<user>(cron output with Postfix) and/var/mail/root(bounces); state and pid files of Postfix and syslog-ng/var/mail/<user>: #667; the rest left/opt/docker/etc/logrotate.d/syslog-ng/var/log/syslogand others; logrotate is not installed and nothing writes these filesgo-replace … Error: no files specifiedfrompostfix.d/10-init.shat every start of Postfix; syslog-ng warnings onstats_freq/use-dnsWhat
supervisor.d/*.confof all services (cron,dnsmasq,postfix,ssh,syslog,nginx,apache,php-fpm,blackfire-agent):stdout_logfile=/docker.stdoutandstderr_logfile=/docker.stderrinstead of/dev/stdoutand/dev/stderr. WithoutLOG_STDOUTandLOG_STDERR,/docker.stdoutand/docker.stderrare the stdout and stderr of the container, the same as before; with them, the output goes to the two files. The messages of supervisord itself stay in the container log.provisioning/base/general/bin/service.d/ssh.sh:sshd -D -e, so sshd logs to its stderr, which supervisord passes on, also where no syslog-ng runs.provisioning/nginx/alpine/etc/nginx/nginx.conf:error_log /docker.stderr, as in Debian.docs/customization.md: a new section "Logs" with where each service logs, what supervisord passes on, that syslog-ng dropsauth/authprivand loses what a service sends before it listens, and thatbaseandbase-appneedsyslogforcron,postfixanddnsmasq. "Cron jobs":docker-service enable syslog cronforbase. "supervisord" says to use/docker.stdoutand/docker.stderrfor a program of your own.docs/environment-variables.md:LOG_STDOUTandLOG_STDERRname what goes there now, and that the messages of supervisord stay in the container log;SERVICE_SSH_OPTSis forsshd -D -e.docs/known-issues.md: a new entry for what stays: the slow log of PHP-FPM, which needsSYS_PTRACEfor its backtrace (cap_add).docs/README.md,AGENTS.md: one line each.make generate.Changes in behaviour for existing users
LOG_STDOUTorLOG_STDERR, what the services print themselves goes to these files and no longer todocker logs: the output of the start scripts and hooks of the services, the output of cron jobs in Alpine, the messages of sshd and the Blackfire agent, start errors of Nginx, Apache and PHP-FPM before they open their logs.docker logskeeps the output of the entrypoint, the messages of supervisord itself and ofdocker-healthcheck.LOG_STDOUTandLOG_STDERRmean, on purpose: they stand for the container log as a whole, not for the access and error log of the web server. The messages of syslog-ng, for example of cron and Postfix, already went there before. IfLOG_STDOUTpoints at a file that a tool reads as a pure access log, for example/var/log/apache2/access.log, these lines now land there too. The docs of the two variables and the section "Logs" say so.LOG_STDOUTandLOG_STDERR, nothing changes:/docker.stdoutand/docker.stderrare the stdout and stderr of the container, and the output stays indocker logs, stdout and stderr apart (new test below).[SYSLOG]in front, also its start messageServer listening on 0.0.0.0 port 22. Before, syslog-ng dropped them.LOG_STDERR, not to stdout.Tests
New image tests, in the environment container, which has
LOG_STDOUTandLOG_STDERR:ContainerEnvironmentChecks::testServiceOutputReachesTheFilesFromTheEnvironment(all images;baseandbase-appstart syslog-ng for it): the hook of syslog-ng fromHooks/writes a line to stdout and one to stderr; they are in the files ofLOG_STDOUTandLOG_STDERR.SshChecks::testSshLogsToTheFileFromTheEnvironment(development images): a login of an unknown user over port 2222 fails, andInvalid user image-test-nobody from 127.0.0.1is in the file ofLOG_STDERR.NginxEnvironmentChecks::testNginxMainErrorLogToTheFileFromTheEnvironment(php-nginx,php-nginx-dev): afterkill -9of a worker,[alert] … worker process … exited on signal 9is in the file ofLOG_STDERR, not in that ofLOG_STDOUT.And one without
LOG_STDOUTandLOG_STDERR:ContainerEnvironmentChecks::testServiceOutputReachesTheContainerLogWithoutTheEnvironment(all images; a container of its own withoutLOG_*, which starts syslog-ng where the image does not): the two lines of the hook of syslog-ng are indocker logs, the first on its stdout, the second on its stderr. It passes before and after: it guards the behaviour withoutLOG_*.These tests do not check that a line is missing from
docker logs: atSERVICE_SUPERVISOR_OPTS=--loglevel=traceof the environment container, supervisord repeats the output of the services in its own messages.All image tests of each image, before (the published image with the files of master on top, including #656) and after (the same with this change). These runs were made before the output of cron jobs moved to #667;
testCronJobOutputReachesTheFilesFromTheEnvironmentwent with it.php:8.5,php:8.5-alpine,php-apache:8.5,php-apache:8.5-alpine,php-nginx:8.5testServiceOutputReachesTheFilesFromTheEnvironmentfailsphp-nginx:8.5-alpinetestNginxMainErrorLogToTheFileFromTheEnvironmentfailphp-dev:8.5,php-dev:8.5-alpine,php-nginx-dev:8.5,php-apache-dev:8.5,php-apache-dev:8.5-alpinetestSshLogsToTheFileFromTheEnvironmentfailphp-nginx-dev:8.5-alpinebase:ubuntu-22.04,base-app:ubuntu-22.04testServiceOutputReachesTheFilesFromTheEnvironmentfailsBefore, the two lines of the hook were in
docker logs, not in the files; for sshd, its file had no line of sshd at all.No other test changes its result. The other failures in these local runs are the same before and after and come from the older local images:
testPhpVersion(PHP 8.5.12),testImagickReportsItsVersion(php:8.5),testDockerImageCleanupandtestZicIsInstalled(Alpine), and in the-devimages whose published image is older than #635 and #651 (supervisor.dwithstartsecs = 0, which the local images keep),testPostfixOptionsFromTheEnvironmentand, in some runs either way,testBlackfireAgentRunsWithTheServerCredentials.The new tests fail on the published images as well (only them run):
php-nginx:8.5andphp-apache:8.5-alpinethe one of the services,php-dev:8.5also the one of sshd,php-nginx-dev:8.5-alpineall three,basethe one of the services.How it was verified
In the images with the change on top (amd64): the published image with the files of this branch copied over, its
supervisor.dfiles changed the same way and the20-setup-php-fpm-pool.shof #656 run. Where a statement depends on Debian or Alpine, both were checked.php:8.5-alpinewith and withoutLOG_STDOUT/LOG_STDERRVERIFY-JOB-OUTon stdout or in the file ofLOG_STDOUT,VERIFY-JOB-ERRand the PHP warning on stderr or in the file ofLOG_STDERR;@rebootjobs tooLOG_STDOUT/LOG_STDERR: supervisord writes there what the services print; its own messages stay in the container logphp-nginx:8.5-alpinewith both variables andSERVICE_NGINX_OPTS=-Znginx: invalid option: "Z"in the file ofLOG_STDERR, the output of the start scripts and hooks of the services in the file ofLOG_STDOUT;docker logshas the output of the entrypoint and the messages of supervisord onlyLOG_STDERR: the messages of sshd and the Blackfire agentphp-dev:8.5,php-dev:8.5-alpinewithPHP_DEBUGGER=blackfireand dummy credentials;basewithsshenabledError sending request to Blackfire API …) in the file, none indocker logs;Server listening on 0.0.0.0 port 22.in the file (base)SERVICE_SSH_OPTS:sshd -D -e, sshd logs to its stderrphp-apache-dev:8.5,php-nginx-dev:8.5-alpine,base: a login of an unknown user;cmdlineof sshdInvalid user verify-nobody from 127.0.0.1 port …andServer listening on 0.0.0.0 port 22.on the stderr of the container;/usr/sbin/sshd -D -ephp-nginx:8.5,php-nginx-dev:8.5-alpine,php-apache-dev:8.5,php-apache:8.5-alpine: https requests for/(403) and a missing page:443on stdout,directory index … forbidden/AH01276on stderr/docker.stderrphp-nginx-dev:8.5-alpine,php-nginx:8.5:kill -9of a worker[alert] … worker process … exited on signal 9on stderrauthandauthpriv, e.g.susu -s /bin/sh application -c true,logger -p auth.info(CRON) INFO (pidfile fd = 3)anddnsmasq[…]: started, version …in some starts, missing in othersdebug, supervisord repeats what the services printphp-nginx:8.5withSERVICE_SUPERVISOR_OPTS=--loglevel=debugDEBG 'syslogd' stdout output:and the lineSYS_PTRACEphp:8.5,php:8.5-alpinewithfpm.pool.request_slowlog_timeout=1s, a request of 3 s, with and without--cap-add SYS_PTRACEexecuting too slowandERROR: failed to ptrace(ATTACH) child …: Operation not permitted (1); with: the backtrace (sleep() /app/php-test.php:58) in the file ofLOG_STDERRstdout_logfile/stderr_logfilelines ofsupervisor.dchanged inphp-nginx:8.5and the hook of syslog-ng copied in, the two hook lines are on the stdout and stderr ofdocker logswithoutLOG_*, and only in the two files withLOG_STDOUT=/tmp/out.log LOG_STDERR=/tmp/err.log.ci/: the PHPUnit tests ofci/(341) pass, and PHPStan (level 8) finds nothing.