Skip to content

Commit

Permalink
Fix tini signal forwarding in docker containers.
Browse files Browse the repository at this point in the history
Previous: 'sh' starts as the child process of 'tini', but 'sh' does
          not forward signals to its children.

Now: 'sh' is called with 'exec' which replaces the shell process
     by the java process.

Signed-off-by: Yufei Cai <yufei.cai@bosch.io>
Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
yufei-cai authored and thjaeckle committed Aug 18, 2022
1 parent c85f064 commit 7fd2965
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dockerfile-release
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ RUN set -x \
USER ditto
WORKDIR $DITTO_HOME
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["java", "${JVM_CMD_ARGS_ENV}", "${MAIN_CLASS_ENV}"]
CMD ["sh", "-c", "exec java ${JVM_CMD_ARGS_ENV} ${MAIN_CLASS_ENV}"]
2 changes: 1 addition & 1 deletion dockerfile-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ RUN set -x \
USER ditto
WORKDIR $DITTO_HOME
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["java", "${JVM_CMD_ARGS_ENV}", "${MAIN_CLASS_ENV}"]
CMD ["sh", "-c", "exec java ${JVM_CMD_ARGS_ENV} ${MAIN_CLASS_ENV}"]

COPY ${TARGET_DIR}/${SERVICE_STARTER}-${SERVICE_VERSION}-allinone.jar $DITTO_HOME
2 changes: 1 addition & 1 deletion dockerfile-snapshot-arm64
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ RUN set -x \
USER ditto
WORKDIR $DITTO_HOME
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["java", "${JVM_CMD_ARGS_ENV}", "${MAIN_CLASS_ENV}"]
CMD ["sh", "-c", "exec java ${JVM_CMD_ARGS_ENV} ${MAIN_CLASS_ENV}"]

COPY ${TARGET_DIR}/${SERVICE_STARTER}-${SERVICE_VERSION}-allinone.jar $DITTO_HOME

0 comments on commit 7fd2965

Please sign in to comment.