Skip to content

Conversation

@HofmeisterAn
Copy link
Collaborator

What does this PR do?

Docker Engine v29 introduces breaking changes that make Testcontainers and the Docker.DotNet implementation incompatible. I had a quick chat with @eddumelendez, who mentioned that pinning the API to version 1.44, which is the most widely used and compatible version, works as a temporary workaround until Docker.DotNet and Testcontainers fully support the new version. This was also mentioned in the blog post referenced in the release notes.

@KSlingerland It would be really helpful if you could test pinning the version as mentioned in the issue. After that, I think we can merge the PR and publish a new version quickly.

Why is it important?

Makes sure Testcontainers for .NET works with Docker Engine v29.

Related issues

@HofmeisterAn HofmeisterAn added the enhancement New feature or request label Nov 13, 2025
@netlify
Copy link

netlify bot commented Nov 13, 2025

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit c7a749b
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/69173ccf2fd32c0008e4d0ce
😎 Deploy Preview https://deploy-preview-1576--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Summary by CodeRabbit

  • New Features

    • Added support for configurable Docker API version via the DOCKER_API_VERSION environment variable or docker.api.version property file setting, with a default value of 1.44.
    • Docker client initialization now uses the specified API version for enhanced compatibility control.
  • Tests

    • Updated test fixtures to use newer Docker image versions for improved testing environments.

Walkthrough

This change introduces configurable Docker API version support across Testcontainers. A new DOCKER_API_VERSION environment variable and configuration property (defaulting to 1.44) enable users to specify the Docker API version. The version is passed through authentication providers to the Docker client factory during initialization.

Changes

Cohort / File(s) Summary
Documentation
docs/custom_configuration/index.md
Added DOCKER_API_VERSION property mapping table row with default value 1.44.
Configuration Interface & Base
src/Testcontainers/Configurations/ICustomConfiguration.cs, src/Testcontainers/Configurations/CustomConfiguration.cs
Added ICustomConfiguration.GetDockerApiVersion() method and protected virtual helper to parse Docker API version from property values.
Configuration Implementations
src/Testcontainers/Configurations/EnvironmentConfiguration.cs, src/Testcontainers/Configurations/PropertiesFileConfiguration.cs
Implemented GetDockerApiVersion() in both environment and properties-based configuration classes.
Settings & Endpoint Auth
src/Testcontainers/Configurations/TestcontainersSettings.cs, src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs, src/Testcontainers/Configurations/AuthConfigs/IDockerEndpointAuthenticationConfiguration.cs
Added static DockerApiVersion property to TestcontainersSettings with fallback to 1.44; exposed Version property in endpoint authentication configuration interface and implementation.
Authentication Providers
src/Testcontainers/Builders/DockerDesktopEndpointAuthenticationProvider.cs, src/Testcontainers/Builders/TestcontainersEndpointAuthenticationProvider.cs
Added GetDockerApiVersion() methods to both providers.
Docker Client Integration
src/Testcontainers/Clients/DockerApiClient.cs, src/Testcontainers/Builders/DockerEndpointAuthenticationProvider.cs
Updated Docker client creation calls to pass authConfig.Version as argument.
Test Fixtures
tests/Testcontainers.Tests/Fixtures/Containers/Unix/DockerTlsFixture.cs, tests/Testcontainers.Tests/Fixtures/Containers/Unix/OpenSsl3_1Fixture.cs
Updated base image tags from 20.10.18 / 24.0.5 to 29.0.0.
Configuration Tests
tests/Testcontainers.Tests/Unit/Configurations/CustomConfigurationTest.cs
Added GetDockerApiVersionCustomConfiguration theory tests for EnvironmentConfiguration and PropertiesFileConfiguration.
Integration Test
tests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs
Updated MTlsOpenSsl1_1_1 fixture to implement IDockerEndpointAuthenticationConfiguration with Version property returning null.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Settings as TestcontainersSettings
    participant EnvConfig as EnvironmentConfiguration
    participant PropsConfig as PropertiesFileConfiguration
    participant AuthConfig as DockerEndpointAuthenticationConfiguration
    participant Client as DockerApiClient
    participant Docker as Docker Engine

    User->>Settings: Access DockerApiVersion
    Settings->>EnvConfig: GetDockerApiVersion()
    alt Env var set
        EnvConfig-->>Settings: Version
    else Env var missing
        Settings->>PropsConfig: GetDockerApiVersion()
        alt Property set
            PropsConfig-->>Settings: Version
        else Property missing
            Settings-->>Settings: Default 1.44
        end
    end
    Settings->>AuthConfig: Version property
    AuthConfig-->>Client: authConfig.Version
    Client->>Docker: CreateClient(version)
    Docker-->>Client: Configured client
    Client-->>User: Success
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Consistent pattern applied across multiple files: new GetDockerApiVersion() methods added to configuration classes following existing patterns
  • Version parsing logic is straightforward with fallback to null on failure
  • Docker client creation integration is minimal (single parameter addition)
  • Test coverage mirrors existing test structure with theory-based parameterized tests
  • Fixture version updates are routine maintenance changes

Areas requiring attention:

  • Verify Version.TryParse() behavior matches Docker API versioning expectations (e.g., "1.44" vs "v1.44")
  • Confirm default version 1.44 is compatible across targeted Docker Engine versions
  • Validate that passing Version to CreateClient() doesn't break backward compatibility with older Docker.DotNet versions

Poem

🐰 A version here, a version there,
Docker APIs everywhere!
From env to props we parse with care,
Forty-four's our default fare,
Twenty-nine now runs the test with flair! 🚀

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Out of Scope Changes check ❓ Inconclusive Some fixture version updates (DockerTlsFixture, OpenSsl3_1Fixture) from 20.10.18/24.0.5 to 29.0.0 appear tangentially related but lack clear justification in the PR description. Clarify whether fixture version updates are necessary for the Docker API version configuration feature or if they should be addressed separately.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Support configuring Docker API version' clearly and concisely summarizes the main change of adding Docker API version configuration support.
Description check ✅ Passed The PR description includes all mandatory sections (What does this PR do, Why is it important) and recommended sections (Related issues). It provides clear rationale and context.
Linked Issues check ✅ Passed The PR successfully implements Docker API version configuration addressing issue #1575, allowing users to pin Docker API to version 1.44 to work around Docker Engine v29 compatibility issues.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/allow-configuring-the-docker-api-version

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aa40a93 and c2b334f.

📒 Files selected for processing (5)
  • src/Testcontainers/Builders/DockerEndpointAuthenticationProvider.cs (1 hunks)
  • src/Testcontainers/Clients/DockerApiClient.cs (1 hunks)
  • src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs (2 hunks)
  • src/Testcontainers/Configurations/AuthConfigs/IDockerEndpointAuthenticationConfiguration.cs (1 hunks)
  • tests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-11-08T09:04:00.045Z
Learnt from: HofmeisterAn
Repo: testcontainers/testcontainers-dotnet PR: 1509
File: tests/Testcontainers.Grafana.Tests/GrafanaContainerTest.cs:45-46
Timestamp: 2025-11-08T09:04:00.045Z
Learning: In xUnit.net test methods in the testcontainers-dotnet project, ConfigureAwait(true) is recommended and correct to use, as it ensures proper synchronization context capture for xUnit's test parallelism management. Do not suggest changing ConfigureAwait(true) to ConfigureAwait(false) in test methods.

Applied to files:

  • tests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs
🧬 Code graph analysis (4)
src/Testcontainers/Builders/DockerEndpointAuthenticationProvider.cs (1)
src/Testcontainers/Configurations/CustomConfiguration.cs (1)
  • Version (18-21)
src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs (5)
src/Testcontainers/Builders/DockerDesktopEndpointAuthenticationProvider.cs (1)
  • Version (29-32)
src/Testcontainers/Configurations/CustomConfiguration.cs (1)
  • Version (18-21)
src/Testcontainers/Builders/TestcontainersEndpointAuthenticationProvider.cs (1)
  • Version (61-64)
src/Testcontainers/Configurations/EnvironmentConfiguration.cs (4)
  • Version (89-92)
  • EnvironmentConfiguration (11-195)
  • EnvironmentConfiguration (49-51)
  • EnvironmentConfiguration (56-80)
src/Testcontainers/Configurations/PropertiesFileConfiguration.cs (6)
  • Version (60-64)
  • PropertiesFileConfiguration (12-184)
  • PropertiesFileConfiguration (14-16)
  • PropertiesFileConfiguration (21-24)
  • PropertiesFileConfiguration (30-35)
  • PropertiesFileConfiguration (41-51)
src/Testcontainers/Clients/DockerApiClient.cs (5)
src/Testcontainers/Builders/DockerDesktopEndpointAuthenticationProvider.cs (1)
  • Version (29-32)
src/Testcontainers/Configurations/CustomConfiguration.cs (1)
  • Version (18-21)
src/Testcontainers/Builders/TestcontainersEndpointAuthenticationProvider.cs (1)
  • Version (61-64)
src/Testcontainers/Configurations/EnvironmentConfiguration.cs (1)
  • Version (89-92)
src/Testcontainers/Configurations/PropertiesFileConfiguration.cs (1)
  • Version (60-64)
tests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs (5)
tests/Testcontainers.Tests/Fixtures/Containers/Unix/OpenSsl1_1_1Fixture.cs (1)
  • OpenSsl1_1_1Fixture (8-10)
src/Testcontainers/Builders/MTlsEndpointAuthenticationProvider.cs (1)
  • IDockerEndpointAuthenticationConfiguration (40-45)
src/Testcontainers/Builders/TlsEndpointAuthenticationProvider.cs (1)
  • IDockerEndpointAuthenticationConfiguration (66-71)
src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs (1)
  • DockerClientConfiguration (46-53)
src/Testcontainers/Clients/TestcontainersClient.cs (3)
  • TestcontainersClient (21-433)
  • TestcontainersClient (47-57)
  • TestcontainersClient (59-75)
🔇 Additional comments (7)
src/Testcontainers/Configurations/AuthConfigs/IDockerEndpointAuthenticationConfiguration.cs (1)

13-17: LGTM!

The new Version property is well-documented and appropriately marked as nullable, allowing implementations flexibility in specifying the Docker API version.

src/Testcontainers/Configurations/AuthConfigs/DockerEndpointAuthenticationConfiguration.cs (2)

13-14: LGTM - Intentional default to Docker API version 1.44.

The fallback to version 1.44 aligns with the PR objective to work around Docker Engine v29 breaking changes. The initialization chain correctly checks environment variables and properties file before falling back to the default.


36-37: LGTM!

The Version property correctly exposes the configured Docker API version through the interface.

src/Testcontainers/Builders/DockerEndpointAuthenticationProvider.cs (1)

44-44: LGTM - Consistent with Docker API version configuration pattern.

This change correctly passes the configured API version when creating the Docker client, consistent with the approach in DockerApiClient.cs.

tests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs (2)

24-48: LGTM - Test correctly overrides Version for legacy Docker image compatibility.

The test appropriately implements IDockerEndpointAuthenticationConfiguration and returns null for Version to maintain compatibility with the older Docker image (20.10.18) used by the OpenSsl1_1_1Fixture. The comment clearly explains the override rationale.


50-63: LGTM!

The test correctly uses this as the authentication configuration, enabling the Version override to take effect when creating the TestcontainersClient.

src/Testcontainers/Clients/DockerApiClient.cs (1)

137-137: No issues found; code is correct as implemented.

Docker.DotNet's DockerClientConfiguration has a CreateClient(System.Version) overload, and when you pass null or omit the Version parameter, the client leaves the version unspecified and lets the SDK negotiate the highest mutually supported API version with the daemon. The code at line 137 safely passes dockerEndpointAuthConfig.Version (which can be null) to this method, and Docker.DotNet handles both null and non-null cases correctly.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@HofmeisterAn HofmeisterAn merged commit 1666ac2 into develop Nov 14, 2025
148 checks passed
@HofmeisterAn HofmeisterAn deleted the feature/allow-configuring-the-docker-api-version branch November 14, 2025 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Azure Servicebus Emulator breaks on Docker Engine v29

2 participants