Skip to content

Commit 30666e0

Browse files
committed
feat: Add Docker Engine v29 support
1 parent 6e27af6 commit 30666e0

File tree

9 files changed

+36
-24
lines changed

9 files changed

+36
-24
lines changed

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.6.2"/>
8-
<PackageVersion Include="Docker.DotNet.Enhanced.X509" Version="3.130.0"/>
9-
<PackageVersion Include="Docker.DotNet.Enhanced" Version="3.130.0"/>
8+
<PackageVersion Include="Docker.DotNet.Enhanced.X509" Version="3.131.1"/>
9+
<PackageVersion Include="Docker.DotNet.Enhanced" Version="3.131.1"/>
1010
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0"/>
1111
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1"/>
1212
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3"/>

build/Tasks.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ public void DotNetTest(SolutionProject project)
1616
Filter = Parameters.TestFilter,
1717
ResultsDirectory = Parameters.Paths.Directories.TestResultsDirectoryPath,
1818
ArgumentCustomization = args => args
19-
.AppendSwitchQuoted("--blame-hang-timeout", "5m"),
19+
// The windows-2025 GH-hosted runner no longer has cached images. Pulling the
20+
// servercore:ltsc2025 image takes significantly longer.
21+
.AppendSwitchQuoted("--blame-hang-timeout", "10m"),
2022
});
2123
}
2224
}

src/Testcontainers/Clients/ContainerConfigurationConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ public ToNetworks(IContainerConfiguration configuration)
9797

9898
public override IEnumerable<KeyValuePair<string, EndpointSettings>> Convert([CanBeNull] IEnumerable<INetwork> source)
9999
{
100-
return source?.Select(network => new KeyValuePair<string, EndpointSettings>(network.Name, new EndpointSettings { Aliases = _configuration.NetworkAliases?.ToList() }));
100+
var endpointSettings = new EndpointSettings { Aliases = _configuration.NetworkAliases?.ToList(), MacAddress = _configuration.MacAddress };
101+
return source?.Select(network => new KeyValuePair<string, EndpointSettings>(network.Name, endpointSettings));
101102
}
102103
}
103104

src/Testcontainers/Clients/DockerContainerOperations.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ public async Task<string> RunAsync(IContainerConfiguration configuration, Cancel
204204
Image = configuration.Image.FullName,
205205
Name = configuration.Name,
206206
Hostname = configuration.Hostname,
207-
MacAddress = configuration.MacAddress,
208207
WorkingDir = configuration.WorkingDirectory,
209208
Entrypoint = converter.Entrypoint,
210209
Cmd = converter.Command,

src/Testcontainers/Clients/TraceProgress.cs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,35 @@ public TraceProgress(ILogger logger)
1515

1616
public void Report(JSONMessage value)
1717
{
18-
#pragma warning disable CA1848, CA2254
19-
20-
if (!string.IsNullOrWhiteSpace(value.Status))
18+
if (value.Error != null)
2119
{
22-
_logger.LogDebug(value.Status.TrimEnd());
23-
}
20+
_logger.LogError(
21+
"ID={ID}: {Error}",
22+
value.ID,
23+
value.Error.Message);
2424

25-
if (!string.IsNullOrWhiteSpace(value.Stream))
26-
{
27-
_logger.LogDebug(value.Stream.TrimEnd());
25+
return;
2826
}
2927

30-
if (!string.IsNullOrWhiteSpace(value.ProgressMessage))
28+
if (value.Progress != null && value.Progress.Total > 0)
3129
{
32-
_logger.LogDebug(value.ProgressMessage.TrimEnd());
30+
var percentage = (double)value.Progress.Current / value.Progress.Total * 100;
31+
32+
_logger.LogDebug(
33+
"ID={ID}: {Status} {Percentage,6:F2}% ({Current}/{Total})",
34+
value.ID,
35+
value.Status,
36+
percentage,
37+
value.Progress.Current,
38+
value.Progress.Total);
3339
}
34-
35-
if (!string.IsNullOrWhiteSpace(value.ErrorMessage))
40+
else
3641
{
37-
_logger.LogError(value.ErrorMessage.TrimEnd());
42+
_logger.LogDebug(
43+
"ID={ID}: {Status}",
44+
value.ID,
45+
value.Status);
3846
}
39-
40-
#pragma warning restore CA1848, CA2254
4147
}
4248
}
4349
}

src/Testcontainers/Containers/ExecResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public readonly struct ExecResult
1414
/// <param name="stdout">The stdout output.</param>
1515
/// <param name="stderr">The stderr output.</param>
1616
/// <param name="exitCode">The exit code.</param>
17-
public ExecResult(string stdout, string stderr, long exitCode)
17+
public ExecResult(string stdout, string stderr, long? exitCode)
1818
{
1919
Stdout = stdout;
2020
Stderr = stderr;
@@ -37,6 +37,6 @@ public ExecResult(string stdout, string stderr, long exitCode)
3737
/// Gets the exit code.
3838
/// </summary>
3939
[PublicAPI]
40-
public long ExitCode { get; }
40+
public long? ExitCode { get; }
4141
}
4242
}

tests/Testcontainers.Commons/CommonImages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ public static class CommonImages
1515

1616
public static readonly IImage Nginx = new DockerImage("nginx:1.22");
1717

18-
public static readonly IImage ServerCore = new DockerImage("mcr.microsoft.com/windows/servercore:ltsc2022");
18+
public static readonly IImage ServerCore = new DockerImage("mcr.microsoft.com/windows/servercore:ltsc2025");
1919
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
windows-2022
1+
windows-2025

tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ public async Task MacAddress()
8989
// Given
9090
const string macAddress = "92:95:5e:30:fe:6d";
9191

92+
await using var network = new NetworkBuilder()
93+
.Build();
94+
9295
await using var container = new ContainerBuilder(CommonImages.Alpine)
9396
.WithEntrypoint(CommonCommands.SleepInfinity)
97+
.WithNetwork(network)
9498
.WithMacAddress(macAddress)
9599
.Build();
96100

0 commit comments

Comments
 (0)