[Bug]: ReusableResourceTest leaks docker resources
0xced opened this issue · comments
Testcontainers version
3.8.0
Using the latest Testcontainers version?
Yes
Host OS
Any
Host arch
Any
.NET version
8.0.204
Docker version
Not relevant
Docker info
Not relevant
What happened?
Running the ShouldReuseExistingResource
test in the ReusableResourceTest
creates a reusable container, a reusable network and a reusable volume. They are properly disposed in the DisposeAsync
method but since these three resources are configured as reusable they are not deleted.
This is not an issue when running on disposable virtual machines for continuous integration scenarios. This is problematic when running on our development machines where those resources with random GUIDs are piling up, though. The accumulation of networks is particularly problematic since it will eventually lead to this error: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network, rendering Docker unusable until running docker network prune
manually.
Both DockerNetwork
and DockerVolume
have a public DeleteAsync
method but those classes are internal. The DockerContainer
class is public but has no DeleteAsync
method so I'm not sure what's the best way to fix this issue.
Besides the issue about the test I had already wondered how a reusable Docker resource could be deleted programatically using the Testcontainers API.
Relevant log output
No response
Additional information
No response