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.
StopAsync
will just stop the container. All ressources remain. You can start the container in the same .NET Testcontainers run again.CleanUpAsync
will 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.DisposeAsync
chooses between these too implementations, it depends on whether you setWithCleanUp
or not. By default, it is set totrue
.It is not necessary to call
StopAsync
orCleanUpAsync
if you are using theawait using
pattern.DisposeAsync
helps to reduce the cleanup code. Usually, you setWithCleanUp
tofalse
…