just-containers / s6-overlay

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

Installing S6 on official php-fpm container shows no log output from S6 #550

Closed bkuhl closed 1 year ago

bkuhl commented 1 year ago

Please provide a small Dockerfile that demonstrates your issue.

I'm trying to use s6 to create a php-fpm & nginx container, however I'm encountering an issue where I don't see any kind of s6 output in the logs at all indicating any kind of s6 bootup.

FROM php:8.2-fpm

RUN apt-get update && \
    apt-get install -y nginx procps && \
    rm -rf /var/lib/apt/lists/*

# S6 Overlay will manage multiple process within the container
ENV S6_OVERLAY_VERSION 3.1.5.0
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz

COPY ./services.d /etc/services.d

ENTRYPOINT ["/init"]
CMD []

My services.d/nginx/run file is:

#!/usr/bin/execlineb -P
nginx -g "daemon off;"

When I run the container, I can see:

$ docker top [CONTAINER_NAME] acxf  
PID                 TTY                 STAT                TIME                COMMAND
16674               ?                   Ssl                 0:00                \_ s6-linux-init

I've noticed that I can ssh into the container and execute the .../nginx/run file directly and nginx starts up and I can see more processes via docker top ... command.

Can't quite figure out what I'm doing wrong here or if there's an issue with S6.

If you've identified a fix, please open a pull request.

If you've found an issue and know the fix, please open a pull request with your fix.

skarnet commented 1 year ago

That is weird: the s6-linux-init process should never block and never sleep. Can you check what it's blocking on, via (as root) strace -p 16674 or whatever its pid is?

As an aside, if you want to use #!/usr/bin shebangs for execlineb, you will need to install the symlinks-noarch tarball, because the s6-overlay binaries aren't accessible via /usr/bin anymore otherwise.

bkuhl commented 1 year ago

I've changed the shebang to just #!/bin/sh for now, since that's really all I need anyways.

$ docker top [CONTAINER_NAME] acxf
PID                 TTY                 STAT                TIME                COMMAND
21654               ?                   Ssl                 0:00                \_ s6-linux-init

So I SSH'd into the container and got this:

$ strace -p 21654
strace: attach: ptrace(PTRACE_SEIZE, 21654): No such process
$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0 144208  3968 ?        Ssl  16:40   0:00 /usr/bin/qemu-x86_64 /package/admin/s6-linux-init/command/s6-linux-init /package/admin/s6-linux-i
root        23  0.0  0.0   2320  1280 pts/1    Ss   16:44   0:00 /bin/sh
root        33  0.0  0.0   8044  3712 pts/1    R+   16:44   0:00 ps aux
$ strace -p 1
strace: attach: ptrace(PTRACE_SEIZE, 1): Operation not permitted

I also tried running the container with --security-opt seccomp=unconfined --privileged options and the results were the same.

bkuhl commented 1 year ago

Switching back to v2 resolves the issue and shows logs and output when my container starts.

ADD https://github.com/just-containers/s6-overlay/releases/download/v2.2.0.1/s6-overlay-amd64-installer /tmp/
RUN chmod +x /tmp/s6-overlay-amd64-installer && /tmp/s6-overlay-amd64-installer /
skarnet commented 1 year ago

Why is pid 1 a qemu-x86_64 process? Are you trying to run x86_64 binaries on a non-x86 architecture?

Please use hardware-appropriate binaries.

bkuhl commented 1 year ago

🤦 I think you're right... was definitely on an ARM device using the AMD binary. Been a while since I've had an issue with that and in this case, the v2 amd binary works no problem on an arm device so I didn't think a thing of it. I appreciate your time and apologize for wasting it.