krallin / tini

A tiny but valid `init` for containers
MIT License
9.66k stars 505 forks source link

Ubuntu 22.04 LTS tini install not working #222

Open eroji opened 4 months ago

eroji commented 4 months ago

I'm using Ubuntu 22.04 LTS as base image and running a couple child processes spawned by my entrypoint script in exec mode. I've installed tini via apt and the version is 0.19.0. However, even when I start tini as PID 1, it is not sending SIGTERM to my child processes as I expected. What am I missing here?

eroji commented 4 months ago

Here is a shot of the process list

UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 00:31 ?        00:00:00 /usr/bin/tini -s -- /usr/local/bin/entrypoint.sh
root           7       1  0 00:31 ?        00:00:00 /bin/bash /usr/local/bin/entrypoint.sh
root           8       7  0 00:31 ?        00:00:00 sudo -u naemon /usr/bin/naemon /etc/naemon/naemon.cfg
root           9       7  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
root          11       7  0 00:31 ?        00:00:00 /usr/lib/postfix/sbin/master -d -c /etc/postfix
root          12       7  0 00:31 ?        00:00:00 /usr/sbin/xinetd -dontfork -pidfile /run/xinetd.pid
naemon        13       8  0 00:31 ?        00:00:00 /usr/bin/naemon /etc/naemon/naemon.cfg
naemon        15      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        16      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        17      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        18      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        19      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        20      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        21      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
naemon        22      13  0 00:31 ?        00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh
www-data      29       9  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
naemon        31      13  0 00:31 ?        00:00:00 /usr/bin/naemon /etc/naemon/naemon.cfg
root          32       9  0 00:31 ?        00:00:00 perl -x /usr/share/thruk/thruk_auth
root          33       9  0 00:31 ?        00:00:00 perl -x /usr/share/thruk/thruk_auth
www-data      35       9  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
www-data      37       9  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
www-data      39       9  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
www-data      41       9  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
www-data      42       9  0 00:31 ?        00:00:00 /usr/sbin/apache2 -D NO_DETACH
postfix       48      11  0 00:31 ?        00:00:00 pickup -l -t unix -d -u -c
postfix       49      11  0 00:31 ?        00:00:00 qmgr -l -t unix -d -u
root          90       0  1 00:31 pts/0    00:00:00 bash
root         103      90  0 00:31 pts/0    00:00:00 ps -ef
krallin commented 4 months ago

There’s a lot of processes in your hierarchy here. Tini sends SIGTERM to its immediate child (or the whole process group if you use the -g flag).

You probably need your shell script to use “exec” to remove the shell itself from this hierarchy and you should perhaps consider using a tool to change the user that also uses exec (back when I was more involved in this the tool to do that was gosu, not sudo, but perhaps that changed)

On Fri, 15 Mar 2024 at 00:32, Jimmy Chen @.***> wrote:

Here is a shot of the process list

UID PID PPID C STIME TTY TIME CMD root 1 0 0 00:31 ? 00:00:00 /usr/bin/tini -s -- /usr/local/bin/entrypoint.sh root 7 1 0 00:31 ? 00:00:00 /bin/bash /usr/local/bin/entrypoint.sh root 8 7 0 00:31 ? 00:00:00 sudo -u naemon /usr/bin/naemon /etc/naemon/naemon.cfg root 9 7 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH root 11 7 0 00:31 ? 00:00:00 /usr/lib/postfix/sbin/master -d -c /etc/postfix root 12 7 0 00:31 ? 00:00:00 /usr/sbin/xinetd -dontfork -pidfile /run/xinetd.pid naemon 13 8 0 00:31 ? 00:00:00 /usr/bin/naemon /etc/naemon/naemon.cfg naemon 15 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 16 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 17 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 18 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 19 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 20 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 21 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh naemon 22 13 0 00:31 ? 00:00:00 /usr/bin/naemon --worker /var/lib/naemon/naemon.qh www-data 29 9 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH naemon 31 13 0 00:31 ? 00:00:00 /usr/bin/naemon /etc/naemon/naemon.cfg root 32 9 0 00:31 ? 00:00:00 perl -x /usr/share/thruk/thruk_auth root 33 9 0 00:31 ? 00:00:00 perl -x /usr/share/thruk/thruk_auth www-data 35 9 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH www-data 37 9 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH www-data 39 9 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH www-data 41 9 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH www-data 42 9 0 00:31 ? 00:00:00 /usr/sbin/apache2 -D NO_DETACH postfix 48 11 0 00:31 ? 00:00:00 pickup -l -t unix -d -u -c postfix 49 11 0 00:31 ? 00:00:00 qmgr -l -t unix -d -u root 90 0 1 00:31 pts/0 00:00:00 bash root 103 90 0 00:31 pts/0 00:00:00 ps -ef

— Reply to this email directly, view it on GitHub https://github.com/krallin/tini/issues/222#issuecomment-1999086470, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANIHVQDOPXSU65YR3UFURLYYKPZLAVCNFSM6AAAAABEXPU75KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJZGA4DMNBXGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>