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=trueGotchas
- 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
How to Reuse Containers Across Test Runs With TestcontainersEnable testcontainers.reuse.enable and withReuse(true) to keep a container alive between runs for faster loca…
How to Choose Docker-in-Docker vs Socket Mount for Self-Hosted RunnersCompare Docker-in-Docker and mounting the host Docker socket for running Testcontainers on self-hosted runner…
How to Meet the Docker Requirement for Testcontainers in CITestcontainers needs a working Docker daemon; GitHub-hosted Linux runners already provide one, so verify it w…