Suport Docker TLS endpoint with client certificate authentication
See original GitHub issueIs your feature request related to a problem? Please describe.
GitLab CI allows to use Docker-in-Docker (DinD) to execute various Docker related tasks. The DinD configuration within the public GitLab CI enforces the usage of TLS to connect to the Docker daemon which is apparently not supported by dotnet-testconainers.
Describe the solution you’d like
It would be nice to either have the option to further configure the DockerClientConfiguration e.g. with a Lambda like it’s quite common with ASP.NET Core to be able to set e.g. credentials or to expose a WithDockerEnvEndpoint method that takes the common environment variables:
DOCKER_HOSTDOCKER_TLS_VERIFYDOCKER_TLS_CERTDIR/DOCKER_CERT_PATH
into account and configures the Docker client accordingly.
Describe alternatives you’ve considered
Setting the DockerEndpoint to something like https://docker:2376 allows to connect to the API via TLS already but I couldn’t manage to use the client certs to authorize myself.
There are probably other options e.g. with a nginx proxy between the client and the API but I don’t consider them actually very practical.
It would also be sufficient to be able to pass in a pre-configured Docker client or register a pre-configured client previously.
Additional context
The GitLab CI docs might also be interesting for further details, paths, etc.
Of course I’d be glad to create a PR to implement the required changes as soon as you confirmed that this request is valid and the design how to implement it is settled!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:16

Top Related StackOverflow Question
Sounds reasonable!
I’d like to give it a try and create a PR following the suggestion you made.
I’m not sure how fast I can provide the complete PR but I think as I am the only who depends on it right now there’s no reason to hurry 😅
I already had a look at your contribution guide, I’ll try to stick to it as good as I can 😊
https://github.com/HofmeisterAn/dotnet-testcontainers/commit/aed56793f5edfb00791a4085ae6b7e7b0f521f93 (
1.6.0-beta.2251) extends all builder methodsWithDockerEndpoint. It adds an overloaded method that gets an implementation ofIDockerEndpointAuthenticationConfiguration, e.g.: https://github.com/HofmeisterAn/dotnet-testcontainers/blob/aed56793f5edfb00791a4085ae6b7e7b0f521f93/tests/DotNet.Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs#L253You can use this method to do the TLS or any other kind of authentication.
Upcoming tasks:
IDockerEndpointAuthenticationConfigurationin the resource reaperTestcontainersSettings.OS.DockerEndpointAuthConfig)