Repository navigation
Conversation
- Add `-f, --filter` option to `container ls` / `container list` supporting `label=key` (presence) and `label=key=value` (exact match). - Escape special regex characters in label values to guarantee literal matching against the daemon API. - Apply client-side refinement to handle absent vs. empty labels accurately. - Preserve running/all status filtering and machine exclusion. - Add comprehensive unit tests in ContainerListTests covering flag parsing, filter syntax validation, and container matching. - Update command-reference documentation for container list. Fixes apple#2403 Signed-off-by: kavix <kavix@yahoo.com>
Signed-off-by: kavix <kavix@yahoo.com>
dxnnystyles
reviewed
Oct 30, 2026
| labels: serverLabels | ||
| ).withoutMachines() | ||
|
|
||
| let containers = try await client.list(filters: filters) |
There was a problem hiding this comment.
the parser and matching tests cover a good range of label values, including regex-special characters. the one path they don't exercise is the server-side filter sent through client.list. an integration test for that request would be useful to verify that the anchored expression matches the service's filtering behavior.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Motivation and Context
Closes #2403.
This PR adds Docker-compatible label filtering to
container ls/container listvia-f, --filter:--filter label=key/-f label=key--filter label=key=value/-f label=key=value--filtermultiple times (logical AND)1.0.0,foo+bar) to ensure literal matching across the APIkey="")--all/-a) and machine exclusion (.withoutMachines())docs/command-reference.mdTesting