Skip to content

Commit 99c1482

Browse files
committed
chore: allow overrided container runtime when attempting to remove docker volume
1 parent 85169bb commit 99c1482

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/CommunityToolkit.Aspire.Testing/DockerUtils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ public sealed class DockerUtils
99
{
1010
public static void AttemptDeleteDockerVolume(string volumeName, bool throwOnFailure = false)
1111
{
12+
string containerRuntime = Environment.GetEnvironmentVariable("DOTNET_ASPIRE_CONTAINER_RUNTIME") ?? "docker";
13+
1214
for (var i = 0; i < 3; i++)
1315
{
1416
if (i != 0)
1517
{
1618
Thread.Sleep(1000);
1719
}
1820

19-
if (Process.Start("docker", $"volume rm {volumeName}") is { } process)
21+
if (Process.Start(containerRuntime, $"volume rm {volumeName}") is { } process)
2022
{
2123
var exited = process.WaitForExit(TimeSpan.FromSeconds(3));
2224
var done = exited && process.ExitCode == 0;
@@ -32,7 +34,7 @@ public static void AttemptDeleteDockerVolume(string volumeName, bool throwOnFail
3234

3335
if (throwOnFailure)
3436
{
35-
if (Process.Start("docker", $"volume inspect {volumeName}") is { } process)
37+
if (Process.Start(containerRuntime, $"volume inspect {volumeName}") is { } process)
3638
{
3739
var exited = process.WaitForExit(TimeSpan.FromSeconds(3));
3840
var exitCode = process.ExitCode;

0 commit comments

Comments
 (0)