0

当使用 S6 覆盖服务时,我的容器需要关闭,我感到很沮丧。据我了解,s6 应该作为 PID 1 运行,并且应该在您发出 SIGTERM 时向所有子进程(后缀)发出docker stop. 我确认它以 PID 1 运行,但仍需要 10 秒才能停止。我尝试使用 Tini 初始化系统,它会立即关闭。我在这里做错了什么?

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" ]

构建图像:docker build -t test .

运行图像:docker run --name test --rm -d test

4

0 回答 0