Skip to content

feat: add standard org.testcontainers=true label - #969

Open
BrunosGits wants to merge 1 commit into
testcontainers:mainfrom
BrunosGits:fix/926-standard-label
Open

feat: add standard org.testcontainers=true label#969
BrunosGits wants to merge 1 commit into
testcontainers:mainfrom
BrunosGits:fix/926-standard-label

Conversation

@BrunosGits

Copy link
Copy Markdown

Summary

This PR adds the standard org.testcontainers=true label to all containers created by testcontainers-rs, achieving ecosystem consistency with Java and Go implementations.

Changes

  1. testcontainers/src/core/containers/request.rs: Added default labels org.testcontainers=true and org.testcontainers.managed-by=testcontainers in ContainerRequest::from() implementation.

  2. testcontainers/src/runners/async_runner.rs: Updated test async_start_should_apply_expected_labels to expect the new org.testcontainers=true label.

Root Cause

Only org.testcontainers.managed-by=testcontainers was being added by default. Other language implementations (Java, Go) also add org.testcontainers=true for ecosystem consistency. This made it harder to filter/clean up testcontainers across different language implementations using the standard label.

Testing

  • cargo +nightly fmt --all -- --check - PASSED
  • cargo clippy - PASSED
  • cargo test --features blocking - 85 passed (1 pre-existing unrelated failure)
  • cargo test --features blocking sync_runner - 35 passed
  • cargo test --features "blocking reusable-containers" --lib - 89 passed
  • cargo test --all-features --lib - 104 passed
  • async_start_should_apply_expected_labels - PASSED (verifies both labels)

Closes #926

@netlify

netlify Bot commented Aug 26, 2026

Copy link
Copy Markdown

Deploy Preview for testcontainers-rust ready!

Name Link
🔨 Latest commit c9ba30f
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-rust/deploys/6a8e2e2b87b9c8000855494a
😎 Deploy Preview https://deploy-preview-969--testcontainers-rust.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c9ba30fa25

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

labels: BTreeMap::default(),
labels: {
let mut l = BTreeMap::new();
l.insert("org.testcontainers".to_string(), "true".to_string());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Label Docker Compose service containers as well

When the optional docker-compose feature is used, DockerCompose::up delegates to the local or containerized Compose client, which runs docker compose up without adding this label to the supplied compose configuration. Thus ordinary Compose services receive only Compose/user labels (the containerized mode labels at most its Docker CLI helper), so docker ps --filter label=org.testcontainers=true will miss workloads that this library started through its documented Compose API.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the Compose path. That one is intentionally left out of this PR and here is why.

The change targets the Rust runner's own ContainerRequest::from, which covers every container the library starts directly. The docker-compose feature is a separate route that hands off to the Compose CLI, so labeling there means touching a different code path with its own config handling. I kept this PR small and focused on the runner side, which is what the underlying issue (#926) asks for and where the cleanup gap actually bites.

I am happy to follow up with the Compose service labeling as a second PR if the maintainers want it. For now I would rather not widen the diff of this one.

@BrunosGits

Copy link
Copy Markdown
Author

@DDtKey @bergkvist would one of you mind taking a look when you get a chance? I have addressed the bot's P2 note about the Compose path in a reply and kept this PR scoped to the runner's own containers. Tests and fmt and clippy are all green locally. Happy to adjust if you want it handled differently.

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

Successfully merging this pull request may close these issues.

Proposal to add org.testcontainers=true label for ecosystem consistency

1 participant