Skip to content
Latchkey

How to Handle the Ryuk Resource Reaper in Testcontainers CI

Ryuk is a small sidecar that removes containers, networks, and volumes after the test JVM/process exits, so nothing leaks on the runner.

Ryuk starts automatically and reaps Testcontainers resources when the parent process dies. Some restricted environments block the privileges Ryuk needs; TESTCONTAINERS_RYUK_DISABLED=true skips it, but then you are responsible for cleanup.

What Ryuk does

  • Connects to the test process and watches for it to exit.
  • Removes containers, networks, and volumes labeled by Testcontainers.
  • Prevents leaks when a test crashes before calling stop.

Disabling Ryuk (tradeoff)

Terminal
# Only where Ryuk cannot start (e.g. some locked-down runners).
# Ephemeral runners are safe because the whole host is discarded.
export TESTCONTAINERS_RYUK_DISABLED=true

Gotchas

  • Disabling Ryuk on a long-lived self-hosted runner leaks containers over time; clean up manually.
  • On ephemeral GitHub-hosted runners disabling Ryuk is low risk because the host is thrown away after the job.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →