diff --git a/docker/targets/admin-tools.Dockerfile b/docker/targets/admin-tools.Dockerfile index f821ee2985..e958917c29 100644 --- a/docker/targets/admin-tools.Dockerfile +++ b/docker/targets/admin-tools.Dockerfile @@ -29,4 +29,22 @@ COPY ./build/temporal/schema /etc/temporal/schema USER temporal -CMD ["sh", "-c", "trap exit INT HUP TERM; sleep infinity"] +# Keep the container running idle so users can exec into it for admin tasks. +# +# trap exit INT HUP TERM +# Register a signal handler so that when the shell receives SIGINT, SIGHUP, +# or SIGTERM it runs "exit" instead of the default PID 1 behavior (ignore). +# +# sleep infinity & +# Start a never-ending process to keep the container alive. It runs in the +# background ("&") so the shell remains the foreground process. +# +# wait +# Block the shell until background jobs finish. Unlike a foreground "sleep", +# "wait" is a shell builtin that gets interrupted when a signal arrives, +# giving the shell a chance to run the trap handler and exit immediately. +# +# Without the "& wait" pattern, the shell is blocked on the foreground sleep and +# never processes signals, causing the container to hang until the kubelet +# termination deadline before being force-killed. +CMD ["sh", "-c", "trap exit INT HUP TERM; sleep infinity & wait"]