[Feature]: Stabilize Reusable Containers feature and make it GA
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu bằng cách xem xét entry point hiện có của các container có thể tái sử dụng, .withReuse(true), và cấu hình testcontainers.reuse.enable=true, sau đó đọc các issue liên quan #3081 và #7097. Để được coi là hoàn tất, cần giải quyết hoặc ghi lại rõ ràng về networking, việc dọn dẹp tài nguyên, hành vi opt-in và khả năng tương thích với CI trước khi tuyên bố feature là GA.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Module
Core
Problem
The reusable containers feature (.withReuse(true)) has been available as an experimental/alpha feature since its introduction in 2019 via PR #1781. Despite its clear value and widespread adoption by the community, it remains in this unstable state.
Several critical issues prevent its safe and reliable use in production-grade CI/CD pipelines, as explicitly stated in the official documentation:
"Reusable containers are not suited for CI usage and as an experimental feature not all Testcontainers features are fully working (e.g., resource cleanup or networking)."
The most significant unresolved problems include:
-
Networking support — The documentation still lists networking as an area that is not fully working with reusable containers. There has been an issue discussing reusable networks, but its current status is unclear. Even if some fixes have been merged, it's not evident whether the feature now fully supports custom networks or whether there are still edge cases that break reuse.
-
Resource cleanup — The documentation also states that resource cleanup is not fully reliable with reusable containers. A related bug report has been closed, but the comments indicate that the underlying problem may not be completely resolved. Users still report containers not being cleaned up properly between test runs, leading to errors and flooded logs.
-
Explicit opt-in friction — The feature requires both
.withReuse(true)in code andtestcontainers.reuse.enable=truein~/.testcontainers.properties(classpath properties are intentionally not supported). While this explicit opt-in is appropriate for an experimental feature, it adds unnecessary friction for users who want to safely adopt reuse in appropriate environments. -
CI incompatibility — The documentation explicitly states that reusable containers are not suited for CI usage. This is a significant limitation given that many teams would benefit from faster test execution in CI environments (especially on self-hosted runners with persistent Docker daemons).
Solution
We propose that the Testcontainers team prioritize making the Reusable Containers feature Generally Available (GA) by addressing the blockers above. Specifically:
-
Clarify and complete networking support — We request that the team clarify the current status of networking support for reusable containers. If the feature is not yet fully implemented (e.g., custom networks still cause hash mismatches), we ask that it be completed. If it is already implemented, we ask that the documentation be updated to reflect that and remove the warning about networking limitations.
-
Clarify and complete resource cleanup support — Similarly, we ask that the team confirm whether resource cleanup issues are fully resolved. If not, we request that the remaining problems be fixed. If they are resolved, the documentation should be updated to remove the caveat about resource cleanup.
-
Re-evaluate the opt-in mechanism — Consider whether classpath properties could be supported for environments where reuse is always desired (e.g., local development), while keeping the explicit opt-in for safety.
-
Re-evaluate CI compatibility — Investigate whether reuse could be made safe for CI environments, or at least provide clear guidance and workarounds for teams that want to use it in CI.
Benefit
Stabilizing this feature would deliver significant value to the entire Testcontainers ecosystem:
-
Massive performance improvements — Reusing containers shaves off container start times, dramatically speeding up test suites. This is especially valuable for large integration test suites with many containers.
-
Better local development experience — Developers can run tests faster and with less resource consumption, improving productivity.
-
Reduced CI costs — Faster test execution means shorter CI build times and lower infrastructure costs.
-
Increased adoption — Many users are hesitant to use the feature because of its experimental status. Making it GA would encourage broader adoption and unlock its benefits for more projects.
-
Cleaner code — The current workarounds (e.g., manual Docker client checks, reflection to modify internal objects) are fragile and error-prone. A stable, well-documented feature would eliminate the need for these hacks.
Alternatives
Users currently have several workarounds, but none are ideal:
-
Singleton containers in test suites — Define a container once and reuse it across tests within the same JVM instance. This works but does not persist across separate test runs or builds.
-
Manual Docker management — Use the Docker client directly to check if a container exists and reuse it manually. This is fragile, requires extensive boilerplate, and often involves reflection to modify internal Testcontainers objects.
-
External container orchestration — Run containers outside of Testcontainers (e.g., via Docker Compose or a separate service) and connect tests to them. This loses many of Testcontainers' benefits (automatic port mapping, lifecycle management, etc.) and complicates the test setup.
None of these alternatives provide the seamless, reliable experience that a stable, GA implementation would offer.
Thank you for maintaining this excellent project! We believe that stabilizing the Reusable Containers feature would be a significant milestone and would greatly benefit the community. We're happy to help with testing, documentation, or even contributing PRs if given guidance on the preferred approach.
Would you like to help contributing this feature?
Yes
- Ngôn ngữ chính
- Java
- Star
- 8.7k
- Fork
- 1.9k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 9
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của testcontainers/testcontainers-java
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
testcontainers/testcontainers-java#11997 · 1 bình luận ·
-
[Enhancement]: Document why singleton containers are required under Spring's test context caching Đang mởtype/enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
testcontainers/testcontainers-java#11967 ·
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
testcontainers/testcontainers-java#11941 ·
-
type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
testcontainers/testcontainers-java#11829 · 1 bình luận ·
-
type/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
testcontainers/testcontainers-java#11578 ·
Tất cả issue của testcontainers/testcontainers-java
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
apache/cloudstack#14222 ·
-
[BUG]茶杯方块在取茶时会引发崩溃 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Cannot differ own consent and managed consents in My Consents view and detailed consent view. Đang mở1.0.0-alpha2 Type/Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wso2/dpdp-accelerator#272 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
apache/rocketmq-dashboard#4860 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
infinispan/infinispan#18150 ·