Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public void close() {

final String ryukContainerId;

boolean useRyuk = !Boolean.parseBoolean(System.getenv("TESTCONTAINERS_RYUK_DISABLED"));
boolean useRyuk = TestcontainersConfiguration.getInstance().isRyukEnabled();
if (useRyuk) {
log.debug("Ryuk is enabled");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ public String getTinyImage() {
return getImage(ALPINE_IMAGE).asCanonicalNameString();
}

public boolean isRyukEnabled() {
// Environment variable TESTCONTAINERS_RYUK_DISABLED is legacy. Having this boolean expression ensure legacy
// systems will not break.
return !Boolean.parseBoolean(System.getenv("TESTCONTAINERS_RYUK_DISABLED")) &&
Boolean.parseBoolean(getEnvVarOrProperty("ryuk.container.enabled", "true"));
}

public boolean isRyukPrivileged() {
return Boolean
.parseBoolean(getEnvVarOrProperty("ryuk.container.privileged", "false"));
Expand Down
7 changes: 3 additions & 4 deletions docs/features/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ Some companies disallow the usage of Docker Hub, but you can override `*.image`
> In some environments ryuk must be started in privileged mode to work properly (--privileged flag)

### Disabling Ryuk
Ryuk must be started as a privileged container.
If your environment already implements automatic cleanup of containers after the execution,
but does not allow starting privileged containers, you can turn off the Ryuk container by setting
`TESTCONTAINERS_RYUK_DISABLED` **environment variable** to `true`.
> **ryuk.container.enabled = true**
> If your environment already implements automatic cleanup of containers after the execution,
but does not allow starting privileged containers, you can turn off the Ryuk container by setting it to false.

!!!tip
Note that Testcontainers will continue doing the cleanup at JVM's shutdown, unless you `kill -9` your JVM process.
Expand Down