just-containers / s6-overlay

s6 overlay for containers (includes execline, s6-linux-utils & a custom init)
Other
3.73k stars 212 forks source link

My container stop immediately after start #589

Closed shinsenter closed 2 months ago

shinsenter commented 2 months ago

My issue

Hello @skarnet,

I'm currently using s6-overlay in containers running PHP and Apache. Today, after building my Docker images, I encountered an issue where the containers immediately stop after starting. I've tried updating Docker to the latest version and rebuilding the images multiple times, but the problem persists.

To troubleshoot, I enabled S6_VERBOSITY=3 and ran the containers again. I noticed an unusual message: "bringing selected services down" appearing right after the Apache service starts. Interestingly, when I tested a container built from a Docker image created yesterday using the same source code and testing methods, this issue did not occur, and Apache worked perfectly.

I would greatly appreciate any insights or guidance on what might be causing this issue and how to resolve it. Below, I've included the complete log of the container startup process where the problem occurs.


Dockerfile

Source code I used to build the Docker images is here: https://github.com/shinsenter/php/tree/main

Commands I used to build the Docker images:

PLATFORM=arm64 DOCKERTAG=apache DOCKERFILE=php/with-apache.dockerfile PHP_VARIANT=fpm ./tests/squash-test.sh 8.3

Command I ran to test the container built from the above command:

docker run --rm -p 443:443 -p 80:80 -e S6_VERBOSITY=3 -e DISABLE_AUTORUN_SCRIPTS=1 docker-php-8.3-apache:squashed

Command I ran to test the container I built yesterday:

docker run --rm -p 443:443 -p 80:80 -e S6_VERBOSITY=3 -e DISABLE_AUTORUN_SCRIPTS=1 shinsenter/php-archives:20240731-8.3-fpm-apache

Logs

Below is the complete log of the container startup process where the issue occurs for your reference.

# docker run --rm -p 443:443 -p 80:80 -e S6_VERBOSITY=3 -e DISABLE_AUTORUN_SCRIPTS=1 docker-php-8.3-apache:squashed
/package/admin/s6-overlay/libexec/preinit: info: container permissions: uid=0 (root), euid=0, gid=0 (root), egid=0
/package/admin/s6-overlay/libexec/preinit: info: /run permissions: uid=0 (root), gid=0 (root), perms=oxorgxgruxuwur
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/apache
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/crontab
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/php-fpm
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/syslogd
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/syslogd-bundle
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/syslogd-log
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/syslogd-prepare
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/user
s6-rc-compile: info: parsing /etc/s6-overlay/s6-rc.d/user2
s6-rc-compile: info: parsing /package/admin/s6-overlay-3.2.0.0/etc/s6-rc/sources/base
s6-rc-compile: info: parsing /package/admin/s6-overlay-3.2.0.0/etc/s6-rc/sources/fix-attrs
s6-rc-compile: info: parsing /package/admin/s6-overlay-3.2.0.0/etc/s6-rc/sources/legacy-cont-init
s6-rc-compile: info: parsing /package/admin/s6-overlay-3.2.0.0/etc/s6-rc/sources/legacy-services
s6-rc-compile: info: parsing /package/admin/s6-overlay-3.2.0.0/etc/s6-rc/sources/top
s6-rc-compile: info: making bundles for pipelines
s6-rc-compile: info: resolving bundle names
s6-rc-compile: info: resolving service names
s6-rc-compile: info: writing compiled information to /run/s6/db
s6-rc: info: bringing selected services up
s6-rc: info: service s6rc-fdholder: starting
s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service s6rc-fdholder successfully started
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/00-bootstrap
cont-init: info: /etc/cont-init.d/00-bootstrap exited 0
cont-init: info: running /etc/cont-init.d/00-php-conf
cont-init: info: /etc/cont-init.d/00-php-conf exited 0
cont-init: info: running /etc/cont-init.d/00-sendmail
cont-init: info: /etc/cont-init.d/00-sendmail exited 0
cont-init: info: running /etc/cont-init.d/10-create-project
cont-init: info: /etc/cont-init.d/10-create-project exited 0
cont-init: info: running /etc/cont-init.d/10-missing-index
cont-init: info: /etc/cont-init.d/10-missing-index exited 0
cont-init: info: running /etc/cont-init.d/50-autorun
cont-init: info: /etc/cont-init.d/50-autorun exited 0
cont-init: info: running /etc/cont-init.d/50-crontabs
cont-init: info: /etc/cont-init.d/50-crontabs exited 0
cont-init: info: running /etc/cont-init.d/99-other-fixes
cont-init: info: /etc/cont-init.d/99-other-fixes exited 0
cont-init: info: running /etc/cont-init.d/zz-start-apache
Server version: Apache/2.4.61 (Debian)
Server built:   2024-07-07T12:08:26
mkdir: created directory '/var/lock/apache2'
Syntax OK
cont-init: info: /etc/cont-init.d/zz-start-apache exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service syslogd-prepare: starting
s6-rc: info: service php-fpm: starting
s6-rc: info: service crontab: starting
s6-rc: info: service php-fpm successfully started
s6-rc: info: service apache: starting
s6-rc: info: service crontab successfully started
s6-rc: info: service apache successfully started
s6-rc: info: service syslogd-prepare successfully started
s6-rc: info: service syslogd-log: starting
s6-rc: info: service syslogd-log successfully started
s6-rc: info: service syslogd: starting
s6-rc: info: service syslogd successfully started
s6-rc: info: service legacy-services: starting
[01-Aug-2024 10:51:45] NOTICE: fpm is running, pid 344
[01-Aug-2024 10:51:45] NOTICE: ready to handle connections
[Thu Aug 01 10:51:45.226868 2024] [mpm_event:notice] [pid 352:tid 352] AH00489: Apache/2.4.61 (Debian) OpenSSL/3.0.13 configured -- resuming normal operations
[Thu Aug 01 10:51:45.226946 2024] [core:notice] [pid 352:tid 352] AH00094: Command line: 'apache2 -e error -D FOREGROUND'
s6-rc: info: service legacy-services successfully started
s6-rc: info: bringing selected services down
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service syslogd: stopping
s6-rc: info: service crontab: stopping
s6-rc: info: service apache: stopping
s6-rc: info: service syslogd successfully stopped
s6-rc: info: service syslogd-log: stopping
s6-rc: info: service crontab successfully stopped
s6-rc: info: service syslogd-log successfully stopped
s6-rc: info: service syslogd-prepare: stopping
s6-rc: info: service s6rc-fdholder: stopping
s6-rc: info: service syslogd-prepare successfully stopped
s6-rc: info: service s6rc-fdholder successfully stopped
[Thu Aug 01 10:51:45.259612 2024] [mpm_event:notice] [pid 352:tid 352] AH00491: caught SIGTERM, shutting down
s6-rc: info: service apache successfully stopped
s6-rc: info: service php-fpm: stopping
[01-Aug-2024 10:51:45] NOTICE: Terminating ...
[01-Aug-2024 10:51:45] NOTICE: exiting, bye-bye!
s6-rc: info: service php-fpm successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped
skarnet commented 2 months ago

I don't know or understand your exact setup, your source code repository is too complex for me to dive into; and if something worked yesterday and isn't working today, that's certainly not s6-overlay-related, because s6-overlay did not change. But I can see one thing: you seem to have two apache services - one defined in cont-init and started with zz-start-apache, and another one as an s6-rc service. Is that intentional?

shinsenter commented 2 months ago

I’m not entirely sure what happened, but it seems to be working fine now with the recent build using the same source code. It looks like a process in s6-overlay might have sent a signal to close other processes in the container.

Thank you for your support. I’ll close this issue now.

Note: The process named zz-start-apache is actually just for initializing environment variables, creating directories, etc., used for the Apache service.