{"record":{"id":"93fcdaa3d3410e1e","repo":"testcontainers/testcontainers-java","slug":"ryuk-has-been-disabled-this-can-cause-unexpected-behavior-in","errorCode":null,"errorMessage":"Ryuk has been disabled. This can cause unexpected behavior in your environment.","messagePattern":"Ryuk has been disabled\\. This can cause unexpected behavior in your environment\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/testcontainers/utility/ResourceReaper.java","lineNumber":89,"sourceCode":"     * Internal constructor to avoid custom implementations\n     */\n    ResourceReaper() {}\n\n    public static synchronized ResourceReaper instance() {\n        if (instance == null) {\n            boolean useRyuk = !Boolean.parseBoolean(System.getenv(\"TESTCONTAINERS_RYUK_DISABLED\"));\n            if (useRyuk) {\n                //noinspection deprecation\n                instance = new RyukResourceReaper();\n            } else {\n                String ryukDisabledMessage =\n                    \"\\n\" +\n                    \"********************************************************************************\" +\n                    \"\\n\" +\n                    \"Ryuk has been disabled. This can cause unexpected behavior in your environment.\" +\n                    \"\\n\" +\n                    \"********************************************************************************\";\n                LOGGER.warn(ryukDisabledMessage);\n\n                instance = new JVMHookResourceReaper();\n            }\n        }\n\n        return instance;\n    }\n\n    /**\n     * Perform a cleanup.\n     * @deprecated no longer supported API, use {@link DockerClient} directly\n     */\n    @Deprecated\n    public void performCleanup() {\n        registeredContainers.forEach(this::removeContainer);\n        registeredNetworks.forEach(this::removeNetwork);\n        registeredImages.forEach(this::removeImage);\n    }","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/utility/ResourceReaper.java#L71-L107","documentation":"ResourceReaper.instance() warns when Ryuk (the Testcontainers cleanup sidecar container) is disabled via ryuk.disabled=true. Without Ryuk, containers/volumes created by tests are only cleaned by JVM shutdown hooks, which don't run if the JVM is killed — leaving orphaned Docker resources and possibly rate-limit/disk pressure.","triggerScenarios":"TESTCONTAINERS_RYUK_DISABLED=true env var or ryuk.disabled=true in testcontainers.properties when any Testcontainers resource is created and instance() initializes the reaper.","commonSituations":"CI environments disabling Ryuk to avoid privilege/socket-mount issues (e.g. some GitLab/Dind setups); devs copying CI config locally; environments where Ryuk container fails to start so users disable it.","solutions":["Re-enable Ryuk (remove TESTCONTAINERS_RYUK_DISABLED / ryuk.disabled) and fix whatever prevented the Ryuk container from starting","If Ryuk cannot run, ensure the JVM shuts down cleanly (SIGTERM, not SIGKILL) so shutdown hooks reap resources","Periodically run `docker system prune` or Testcontainers' ResourceReaper.instance().performCleanup() manually"],"exampleFix":"// before (testcontainers.properties)\nryuk.disabled=true\n// after: remove the line, or set explicitly\nryuk.disabled=false","handlingStrategy":"fallback","validationCode":"String ryukDisabled = System.getenv(\"TESTCONTAINERS_RYUK_DISABLED\");\nif (\"true\".equals(ryukDisabled)) {\n    log.warn(\"Ryuk disabled — schedule docker system prune or clean shutdown hooks\");\n}","typeGuard":null,"tryCatchPattern":"Runtime.getRuntime().addShutdownHook(new Thread(() -> {\n    try {\n        org.testcontainers.utility.ResourceReaper.instance().performCleanup();\n    } catch (Exception e) {\n        log.warn(\"manual cleanup failed\", e);\n    }\n}));","preventionTips":["Keep Ryuk enabled unless your CI truly cannot run it","When Ryuk is off, ensure JVMs terminate via SIGTERM not SIGKILL","Run periodic docker system prune in CI to clear orphans"],"tags":["testcontainers","ryuk","cleanup","resource-leak"],"backgroundTag":"missing-dependency","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}