fix(php-fpm-nginx): forward nginx logs to stdout/stderr#2
Merged
Conversation
The php-fpm-nginx image installs nginx with Debian's stock /etc/nginx/nginx.conf, which writes: access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log warn; In a container these are regular files inside the overlay fs and never reach `docker logs` / `kubectl logs`. The standalone nginx image already symlinks them to /dev/stdout and /dev/stderr — this brings php-fpm-nginx in line with the same convention. Symptom: an operator running id (Cbox · ID, a Laravel app) on this baseimage saw cbox-init's own startup messages in `kubectl logs` but nothing from nginx (no access lines, no warnings, no upstream errors) and only fragments from PHP-FPM. Symlinking at build time means the existing config keeps writing to /var/log/nginx/access.log + error.log, but those paths now resolve to the container's stdout/stderr. Applied to all 8 stages (slim/standard/chromium/dev × root/rootless).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Problem
The `php-fpm-nginx` image installs nginx with Debian's stock `/etc/nginx/nginx.conf`, which writes:
```
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log warn;
```
Inside a container these are regular files in the overlay filesystem. They never reach `docker logs` / `kubectl logs`. The standalone `nginx` image already does the symlinks — `php-fpm-nginx` just missed them.
Concrete symptom (encountered while running id on this baseimage):
Fix
Symlink the two log files to `/dev/stdout` and `/dev/stderr` at build time:
```dockerfile
RUN mkdir -p /etc/nginx/conf.d /var/log/nginx /run/nginx && \
chown -R www-data:www-data /var/log/nginx /run/nginx && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log
```
The existing nginx config keeps writing to `/var/log/nginx/access.log` and `/var/log/nginx/error.log`; those paths now resolve to the container's stdout/stderr. This is the same convention Docker's official nginx image uses, and is what the standalone `nginx` image in this repo already does.
Applied to all 8 stages: slim/standard/chromium/dev × root/rootless.
Test plan