-
-
Notifications
You must be signed in to change notification settings - Fork 250
Description
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.
I've taken a stab at adding both withRemoveWhenStopped and withAutoRemove here (including tests): main...cbrevik:testcontainers-node:support-configured-auto-remove