feat: support for reusable containers that have been stopped#896
feat: support for reusable containers that have been stopped#896DDtKey merged 3 commits intotestcontainers:mainfrom
Conversation
✅ Deploy Preview for testcontainers-rust ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I believe it closes #893! It's actually the desired behavior IMO, thanks for the contribution! 🚀 |
Integration with Ryuk and reusable-containers is the correct direction and we have plans for that for a while. And I really glad to accept PRs towards this direction. However, as a workaround for your use-case you bc old try to use |
|
Thanks for the quick review! I took a look at the CI failures and it looks due to rate limits on Docker Hub's side. |
|
Don't worry about rate limits, we're aware of it and we will resolve it independently |
|
Could you address clippy warning? Generally LGTM! |
|
Thank you! |
## 🤖 New release * `testcontainers`: 0.26.2 -> 0.26.3 <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.26.3] - 2025-12-24 ### Details #### Features - Support for reusable containers that have been stopped ([#896](#896)) - Support auto-detection of docker-compose client ([#898](#898)) - Allow customizations of host-config ([#899](#899)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Artem Medvedev <i@ddtkey.com>
This PR allows the
reusable-containersfeature to reuse stopped containers.Motivation
I am trying to write integration tests with ClickHouse and Postgres, but I don't want to spin up one container per test. Moving the containers to a static OnceCell works, but unfortunately static variables are not dropped so the containers are not destroyed.
Integrating Ryuk as a solution to works, but the Ryuk container is not able to remove itself. Ryuk will successfully remove all test containers, and then shutdown. In order to avoid generating a Ryuk container per test run, I'd like to use reusable containers. Unfortunately, the current code fail as soon as Ryuk shuts down.
I am actually happy that Ryuk shuts down since that means it won't hog resources. What I want is for the reusable containers to be able to reuse my stopped Ryuk container, since that is the cleanest solution I have found for test container management on OnceCells.