Skip to content
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

Abrupt shutdown not properly handled #727

Open
feelingsonice opened this issue Sep 6, 2024 · 3 comments
Open

Abrupt shutdown not properly handled #727

feelingsonice opened this issue Sep 6, 2024 · 3 comments

Comments

@feelingsonice
Copy link

Run a container through this crate and abruptly shut it down with something like ctrl+c, and the containers would still be running. This leaves docker in an invalid state and either have consequences on subsequent runs or leaves a bunch of dangling containers.

Personally for me, a huge pain of testing with docker is state management. If I programmatically spin up docker containers via invoked system commands, I have to manage its state, figure out if it's actually started, free the ports, shut it down etc. This is just all not worth it for me.

The cornucopia crate, for example, uses the postgres docker to validate SQL schemas and generate sql queries at compile time, and it does this via docker containers created via std::process commands, and its auto-build feature is literally broken right now because it doesn't fully manage the state of the docker containers it created.

testcontainers solves a huge part of this problem for me but I was disappointed to see that it didn't shutdown the containers when w/e program abruptly stopped. It would be really nice if it could at least do a best effort try when this happened :)

@DDtKey
Copy link
Collaborator

DDtKey commented Sep 6, 2024

Hi 👋

Have you tried watchdog feature? It's not comprehensive at the moment, but handles signals and stops containers.

But in general it's known issue and will be covered with #577 (which is high-priority task for us, but any contributions are welcome)

@feelingsonice
Copy link
Author

No idea it existed, how do I used it?

@DDtKey
Copy link
Collaborator

DDtKey commented Sep 6, 2024

Just enable the feature for testcontainers dependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants