Skip to content

Commit

Permalink
feat(#694): Add Resource Reaper (Ryuk) privileged mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
HofmeisterAn committed Dec 12, 2022
1 parent 8db93b2 commit a57b900
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
- 531 Add Docker health status wait strategy (@kfrajtak)
- 640 Add `ITestcontainersBuilder<TDockerContainer>.WithResourceMapping` to copy files or or any binary contents into the created container even before it is started
- 654 Add `ITestcontainersNetworkBuilder.WithOption` (@vlaskal)
- 678 Add support of custom configuration `TESTCONTAINERS_HOST_OVERRIDE` and `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE`.
- 678 Add support of custom configuration `TESTCONTAINERS_HOST_OVERRIDE` and `TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE`
- 694 Add Resource Reaper (Ryuk) privileged mode support (`TESTCONTAINERS_RYUK_CONTAINER_PRIVILEGED`)

### Changed

Expand Down
7 changes: 7 additions & 0 deletions src/Testcontainers/Configurations/TestcontainersSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ static TestcontainersSettings()
public static bool ResourceReaperEnabled { get; set; }
= !PropertiesFileConfiguration.Instance.GetRyukDisabled() && !EnvironmentConfiguration.Instance.GetRyukDisabled();

/// <summary>
/// Gets or sets a value indicating whether the <see cref="ResourceReaper" /> privileged mode is enabled or not.
/// </summary>
[PublicAPI]
public static bool ResourceReaperPrivilegedModeEnabled { get; set; }
= PropertiesFileConfiguration.Instance.GetRyukContainerPrivileged() || EnvironmentConfiguration.Instance.GetRyukContainerPrivileged();

/// <summary>
/// Gets or sets the <see cref="ResourceReaper" /> image.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion src/Testcontainers/Containers/ResourceReaper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ await DefaultLock.WaitAsync(ct)

var resourceReaperImage = TestcontainersSettings.ResourceReaperImage ?? RyukImage;

defaultInstance = await GetAndStartNewAsync(DefaultSessionId, dockerEndpointAuthConfig, resourceReaperImage, UnixSocketMount.Instance, ct: ct)
var requiresPrivilegedMode = TestcontainersSettings.ResourceReaperPrivilegedModeEnabled;

defaultInstance = await GetAndStartNewAsync(DefaultSessionId, dockerEndpointAuthConfig, resourceReaperImage, UnixSocketMount.Instance, requiresPrivilegedMode, ct: ct)
.ConfigureAwait(false);

return defaultInstance;
Expand Down

0 comments on commit a57b900

Please sign in to comment.