Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install tini by default #4

Merged
merged 1 commit into from
May 4, 2022
Merged

Install tini by default #4

merged 1 commit into from
May 4, 2022

Conversation

TimWSpence
Copy link
Contributor

@TimWSpence TimWSpence commented May 4, 2022

📃 What it does

This installs Tini in our base images. Tini is actually built into docker now but only exposed as an option for docker run. Kubernetes doesn't expose this and so we need to build it into the base image instead.

🤔 Why it is important

PID 1 (also known as init) is special in Linux and is build into the kernel. It doesn't get default signal handlers and (most importantly) orphaned processes are re-parented as children of init. Consequently init is expected to wait on all its children in order to reap Zombie processes and prevent leaking PIDs.

This is where Docker is problematic, as the entrypoint to a docker image becomes PID 1 in its process namespace. For our JVM apps, sbt-native-packager makes the JVM PID 1 by default. However, the JVM is not designed to run as init and doesn't handle signals correctly or reap zombie processes. Tini is a very lightweight process designed to run as init in containers and fork your real entrypoint.

The author of Tini has written a very detailed explanation of the above for the curious reader.

Tini is actually built into docker now but only exposed as an option for
`docker run`. Kubernetes doesn't expose this and so we need to build it
into the base image instead.
@TimWSpence TimWSpence merged commit 4495dab into main May 4, 2022
@TimWSpence TimWSpence deleted the tini branch May 4, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants