Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@HofmeisterAn
Copy link
Collaborator

What does this PR do?

Due to a bug or regression in Docker Desktop, I noticed that we're calling StartAsync() for the database container in the Service Bus module twice. Normally, this wouldn't be a problem, but with the current Docker Desktop regression, it breaks the module.

Since our modules don't handle cleaning up dependent resources (because they don't know who owns them), I've decided to remove this special handling from the Service Bus module as well. Testcontainers can resolve the dependency graph and automatically create all necessary resources. There's no need to explicitly override UnsafeCreateAsync(CancellationToken) or UnsafeStartAsync(CancellationToken).

Also, the current implementation is inconsistent. For example, it removes the dependent container but not the associated network.

To reliably remove dependent resources, we'd need to track which ones are created by our internal library and which are passed in to the builder configuration. Even then, reliably deleting orphaned resources within the test process isn't really feasible. Ryuk usually handles that. Resources only get leaked in environments that don't support Ryuk and aren't ephemeral.

The Docker Desktop regression is easy to reproduce: just call docker start <container_id> a second time, and it messes up the port bindings.

PS C:\Users\andre.hofmeister> docker run -d -p 80 httpd
4d08a7c329b699feb515135ee3ad2f13aed3b9cc32b32e0188cdf114fd7f886c

PS C:\Users\andre.hofmeister> docker ps
CONTAINER ID   IMAGE     COMMAND              CREATED         STATUS        PORTS                                       NAMES
4d08a7c329b6   httpd     "httpd-foreground"   2 seconds ago   Up 1 second   0.0.0.0:52299->80/tcp, [::]:52299->80/tcp   musing_lamarr

PS C:\Users\andre.hofmeister> docker start 4d08a7c329b6
4d08a7c329b6

PS C:\Users\andre.hofmeister> docker ps
CONTAINER ID   IMAGE     COMMAND              CREATED         STATUS         PORTS     NAMES
4d08a7c329b6   httpd     "httpd-foreground"   9 seconds ago   Up 9 seconds   80/tcp    musing_lamarr

Why is it important?

Workaround Docker Desktop regression.

Related issues

-

@HofmeisterAn HofmeisterAn added the bug Something isn't working label Jun 16, 2025
@netlify
Copy link

netlify bot commented Jun 16, 2025

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 8bb08a5
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/6850607559189c0008df1b49
😎 Deploy Preview https://deploy-preview-1465--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.

@HofmeisterAn HofmeisterAn merged commit c053761 into develop Jun 17, 2025
200 of 202 checks passed
@HofmeisterAn HofmeisterAn deleted the bugfix/dont-call-container-start-twice branch June 17, 2025 05:34
@dduch
Copy link

dduch commented Jul 2, 2025

@HofmeisterAn @0xced are you going to release a new version with the fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants