question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suport Docker TLS endpoint with client certificate authentication

See original GitHub issue

Is 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_HOST
  • DOCKER_TLS_VERIFY
  • DOCKER_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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:16

github_iconTop GitHub Comments

1reaction
baez90commented, Mar 7, 2021

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 😊

0reactions
HofmeisterAncommented, Jun 7, 2022

https://github.com/HofmeisterAn/dotnet-testcontainers/commit/aed56793f5edfb00791a4085ae6b7e7b0f521f93 (1.6.0-beta.2251) extends all builder methods WithDockerEndpoint. It adds an overloaded method that gets an implementation of IDockerEndpointAuthenticationConfiguration, e.g.: https://github.com/HofmeisterAn/dotnet-testcontainers/blob/aed56793f5edfb00791a4085ae6b7e7b0f521f93/tests/DotNet.Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs#L253

You can use this method to do the TLS or any other kind of authentication.


Upcoming tasks:

  • Consider the IDockerEndpointAuthenticationConfiguration in the resource reaper
  • Detect the system configuration (env variables) automatic and set the right default authentication (TestcontainersSettings.OS.DockerEndpointAuthConfig)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Verify repository client with certificates
We show you how to install a Certificate Authority (CA) root certificate for the registry and how to set the client TLS certificate...
Read more >
Protect the Docker daemon socket
Use TLS (HTTPS) to protect the Docker daemon socket ... If you need Docker to be reachable through HTTP rather than...
Read more >
Automating TLS certificate management in Docker
It's true: The simplest way to add TLS to Docker services is to not add TLS to Docker services. Just terminate TLS at...
Read more >
How to Secure Docker's TCP Socket With TLS
Configured TLS will require clients to present a valid certificate that's signed by the server's certificate authority. To get it working, you ...
Read more >
Securing Docker with TLS certificates
Docker supports using TLS certificates (both on the server and the client) to provide proof of identity. When set up correctly it will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found