Closed michaelmcneilnet closed 10 months ago
This is the default behavior of Testcontainers. Ryuk takes care of cleaning up remaining Docker resources, including images.
It's really not clear that this is opt-out rather than opt-in, as the method is called WithCleanup. This API, and the docs, make it read as if it will only cleanup if you chain in this method.
The docs say WithCleanup "Will remove the image automatically after all tests have been run." This causes confusion, as not specifying it at all will also do this.
Each builder has a set of pre-configurations. Maybe this helps to understand the default configuration (modules OC have much more default values configured):
I see, this isn't very discoverable or intuitive via the API, and would be great if it was called out via the docs and intellisense a bit more.
It's unfortunate that the method wasn't named WithoutCleanup or SkipCleanup, as that would make it clear that, by default, cleanup is enabled.
Testcontainers version
3.5.0
Using the latest Testcontainers version?
Yes
Host OS
Windows with Docker on WSL
Host arch
x86
.NET version
7.0.402
Docker version
Docker info
What happened?
When creating a docker image, it is deleted after the test run, when not specifying
.WithCleanUp
.WithCleanUp(false)
keeps the image aroundWithCleanUp(true)
deletes the imageWithCleanUp
deletes the imageI would expect that omitting
WithCleanUp
would not clean up the image.Relevant log output
No response
Additional information
No response