Properly stop / clean / dispose #410
-
|
I'm trying to understand how to properly dispose a container. I use I checked the source for How do those differ? And should I be using |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
It is not necessary to call |
Beta Was this translation helpful? Give feedback.
-
|
This seems to be the way to think of it, kind of:
|
Beta Was this translation helpful? Give feedback.
-
|
This was helpful, thanks. however I'm finding that images are not deleted. I have both Cleanup and Remove set to true. With is with a mssql container. |
Beta Was this translation helpful? Give feedback.
StopAsyncwill just stop the container. All ressources remain. You can start the container in the same .NET Testcontainers run again.CleanUpAsyncwill remove the container resource. Be aware of #242. We did some further improvements, but there are edge cases where we are not able to remove the container resource yet. Anyway, if you setup a proper test, most cases will work.DisposeAsyncchooses between these too implementations, it depends on whether you setWithCleanUpor not. By default, it is set totrue.It is not necessary to call
StopAsyncorCleanUpAsyncif you are using theawait usingpattern.DisposeAsynchelps to reduce the cleanup code. Usually, you setWithCleanUptofalse…