Skip to content

Commit

Permalink
Propagate SIGTERM for graceful shutdown
Browse files Browse the repository at this point in the history
If the process receiving the signal is PID 1, it gets special treatment
by the kernel; if it hasn't registered a handler for the signal, the
kernel won't fall back to default behavior, and nothing happens. Prior
to this patch, the entrypoint script is PID 1 in the container, and by
default, shell does not register SIGTERM handler. As a result, `docker
stop` will not work properly when trying to gracefully shutdown the
container.

This patch adds `tini` to be the PID 1 in the container to do PID 1
things, and correctly propagate the SIGTERM signal.
  • Loading branch information
jieyu committed Oct 22, 2019
1 parent 6e97a37 commit d1d2d59
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FROM alpine:3.10.1
# experience when this doesn't work out of the box.
#
# OpenSSL is required so wget can query HTTPS endpoints for health checking.
RUN apk add --update ca-certificates openssl curl
RUN apk add --update ca-certificates openssl curl tini

RUN mkdir -p /app/bin
COPY --from=0 /app/bin/dex-k8s-authenticator /app/bin/
Expand All @@ -38,7 +38,7 @@ WORKDIR /app
COPY entrypoint.sh /
RUN chmod a+x /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh"]

CMD ["--help"]

0 comments on commit d1d2d59

Please sign in to comment.