You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In reference to #849 (comment) I'd like to be able to override the default behaviour where a container is cleaned up when it is stopped.
What I suggest is adding a new function on GenericContainer:
withRemoveWhenStopped(removeWhenStopped: boolean)
So the default behaviour is still that the container is removed when you call container.stop(). But to override you can explicitly configure it with .withRemoveWhenStopped(false) when creating the container. It should probably still be possible to override the configured value by options container.stop({ remove: true }).
It also made sense to me that you'd to be able to configure withAutoRemove(autoRemove: boolean), so if the container is stopped in other ways than via the testcontainers-node API it is also cleaned up.
@cbrevik Could you add some info why the logic for adding withRemoveWhenStopped and withAutoRemove cannot just be put in the container.stop({ ... }). IMO having the same option in 2 places, with one overriding the other is confusing
The main use case for me would be if I enable withReuse() on a container, I normally don't want it to be removed when stopped. So it made sense to me that I could configure that "in the same place" as I configure re-use.
Or something like that. I normally "pass" the container somewhere else, and then I have to remember to call container.stop({ remove: false }) in the other module.
It's not a huge deal though, just made sense that it would be configureable somehow to me.
In reference to #849 (comment) I'd like to be able to override the default behaviour where a container is cleaned up when it is stopped.
What I suggest is adding a new function on
GenericContainer
:withRemoveWhenStopped(removeWhenStopped: boolean)
So the default behaviour is still that the container is removed when you call
container.stop()
. But to override you can explicitly configure it with.withRemoveWhenStopped(false)
when creating the container. It should probably still be possible to override the configured value by optionscontainer.stop({ remove: true })
.It also made sense to me that you'd to be able to configure
withAutoRemove(autoRemove: boolean)
, so if the container is stopped in other ways than via thetestcontainers-node
API it is also cleaned up.I've taken a stab at adding both
withRemoveWhenStopped
andwithAutoRemove
here (including tests): main...cbrevik:testcontainers-node:support-configured-auto-removeThe text was updated successfully, but these errors were encountered: