2

I'm frustrated at the time it takes my container to shut down when using the S6 overlay service. As far as i understand, s6 should run as PID 1 and should issue the SIGTERM to all children processes (postfix) when you issue docker stop. I confirmed it is running as PID 1 but still takes 10sec to stop. I tried with Tini init system and it closes instantaneously. What am i doing wrong here?

Dockerfile

FROM ubuntu:latest

# Add S6 Overlay
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 /

# Add S6 Socklog
ADD https://github.com/just-containers/socklog-overlay/releases/download/v3.1.1-1/socklog-overlay-amd64.tar.gz /tmp/
RUN tar xzf /tmp/socklog-overlay-amd64.tar.gz -C /

ARG TZ=America/Denver
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone

RUN ["/bin/bash", "-c","debconf-set-selections <<< \"postfix postfix/mailname string test.com\""] && \
    ["/bin/bash", "-c","debconf-set-selections <<< \"postfix postfix/main_mailer_type string 'Internet Site'\""]

RUN apt update && \
    apt upgrade -y && \
    DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
        postfix && \
    apt -y autoremove && \
    apt -y clean autoclean && \
    rm -drf /var/lib/apt/lists/* /tmp/* /var/tmp /var/cache

ENTRYPOINT ["/init"]
CMD [ "postfix", "start-fg" ]

Build the Image: docker build -t test .

Run the Image: docker run --name test --rm -d test

bmccormick
  • 75
  • 1
  • 8
  • At first sight, it's possible this is related to the situation described in this other SO question: [Speed up docker-compose shutdown](https://stackoverflow.com/q/50534605/9164010). – ErikMD Feb 26 '21 at 19:04
  • IOW, maybe `docker run --name test --rm --init -d test` would lead to a container that can be stopped more quickly(?) – ErikMD Feb 26 '21 at 19:05
  • Anyway to investigate further, you should probably give more details in the question on the code of the ENTRYPOINT (I just guess that `/init` is a shell script…) – ErikMD Feb 26 '21 at 19:06
  • The --init option gives the same result. The /init command comes from S6 - none of this is my code. I am using s6 for init system and postfix is the process i want to run. – bmccormick Feb 26 '21 at 19:09
  • OK so even if that kind of behavior is certainly due to the entrypoint implementation/configuration, your comment indicates that it's unrelated to some custom shell code; so you may want to (1) double-check [in the doc](https://github.com/just-containers/s6-overlay#customizing-s6-behaviour) if some variable or customization would be useful to address this long-stopping issue, or maybe (2) open [an issue](https://github.com/just-containers/s6-overlay/issues) in their repo… − unless another SO contributor has more ideas and possible answers (I'm not an S6 user :) – ErikMD Feb 26 '21 at 19:24
  • I'll post the same in their repo and let you know if i hear anything! – bmccormick Feb 26 '21 at 19:38

0 Answers0