-
-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force Clean Containers on build before start #242
Comments
@mubeda There is already a mechanism to delete remaining containers at the end. See: https://github.com/HofmeisterAn/dotnet-testcontainers/blob/d2469b35d8f7496411ac5ca8d3486b4ab65b8957/src/DotNet.Testcontainers/Clients/TestcontainersClient.cs#L56-L57 Either the event is not triggered or finished in time. The total execution time of all finalizers is limited in .NET Framework. I'm aware that this implementation has some disadvantages. However, it is simple and has always worked in my use cases.
In addition to that. I guess you are mapping the host port It will prevent mapping the same host port multiple times (of course, it's just a workaround and not a proper fix). |
Hey Andre! |
If you kill the process (includes canceling tests), the event is not triggered at all. This is another drawback of the implementation I was talking about. The official implementation uses an independent container as ResourceReaper to kill orphaned containers. This would be a great and very useful feature. If someone starts with the implementation I am happy to jump in. I just can't bring myself to do it at the moment, because I don't need it urgently. |
…rphanedContainersArgs' {Remove PurgeOrphanedContainersArgs.}
Containers with status |
I'm afraid it's not helpful for this issue - because contrainers remain online. |
What status do the containers have? The implementation will only remove containers with status |
… function: ResourceReaper' {Add ResourceReaper.}
… function: ResourceReaper' {Add ResourceReaper.}
… function: ResourceReaper' {Add ResourceReaper.}
… function: ResourceReaper' {Add ResourceReaper.}
Resource Reaper added for Linux containers in |
.WithCleanUp(true) works well if you don't have any crash on your application. But after a crash you cannot build the container again. For Postgresql you get this exception ("Message = "An item with the same key has already been added. Key: 5432/tcp"). Basically you need to go to the docker app and remove the container manually.
It will be really nice that everytime you build a container with the WithCleanUp(true) it forces the delete of the container if it already exist.
Thanks!
The text was updated successfully, but these errors were encountered: