{"id":"2c56bcb36399ea32","repo":"docker/cli","slug":"filtering-is-not-supported-when-specifying-a-list","errorCode":null,"errorMessage":"filtering is not supported when specifying a list of containers","messagePattern":"filtering is not supported when specifying a list of containers","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/command/container/stats.go","lineNumber":244,"sourceCode":"\t\tfor _, ctr := range cs.Items {\n\t\t\tif s := NewStats(ctr.ID); cStats.add(s) {\n\t\t\t\twaitFirst.Add(1)\n\t\t\t\tlog.G(ctx).WithFields(log.Fields{\n\t\t\t\t\t\"container\": ctr.ID,\n\t\t\t\t}).Debug(\"collecting stats for container\")\n\t\t\t\tgo collect(ctx, s, apiClient, !options.NoStream, waitFirst)\n\t\t\t}\n\t\t}\n\n\t\t// make sure each container get at least one valid stat data\n\t\twaitFirst.Wait()\n\t} else {\n\t\t// TODO(thaJeztah): re-implement options.Containers as a filter so that\n\t\t// only a single code-path is needed, and custom filters can be combined\n\t\t// with a list of container names/IDs.\n\n\t\tif len(options.Filters) > 0 {\n\t\t\treturn errors.New(\"filtering is not supported when specifying a list of containers\")\n\t\t}\n\n\t\t// Create the list of containers, and start collecting stats for all\n\t\t// containers passed.\n\t\tfor _, ctr := range options.Containers {\n\t\t\tif s := NewStats(ctr); cStats.add(s) {\n\t\t\t\twaitFirst.Add(1)\n\t\t\t\tlog.G(ctx).WithFields(log.Fields{\n\t\t\t\t\t\"container\": ctr,\n\t\t\t\t}).Debug(\"collecting stats for container\")\n\t\t\t\tgo collect(ctx, s, apiClient, !options.NoStream, waitFirst)\n\t\t\t}\n\t\t}\n\n\t\t// We don't expect any asynchronous errors: closeChan can be closed and disabled.\n\t\tclose(closeChan)\n\t\tcloseChan = nil\n","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/docker/cli/blob/e9452d6e785f6e365712b9d71bd7517591773c86/cli/command/container/stats.go#L226-L262","documentation":"Raised in runStats for `docker stats` when explicit container names/IDs are passed together with --filter. The code has two separate paths — filter-driven discovery (with event subscription) and an explicit container list — and combining them is not yet implemented (a TODO in the source notes filters should eventually subsume the list), so the CLI rejects the combination.","triggerScenarios":"`docker stats --filter label=app=web ctr1` or any `docker stats [containers...]` invocation where options.Filters is non-empty and at least one container argument is given.","commonSituations":"Trying to narrow stats for a known container with a label/status filter; scripts that both compute a container list and pass a standing --filter flag; expecting --filter to behave like it does on docker ps where it composes with other selection.","solutions":["Use only --filter and let docker stats discover matching containers: docker stats --filter label=app=web","Or use only the explicit container list: docker stats ctr1 ctr2","Pre-resolve the filter yourself: docker stats $(docker ps -q --filter label=app=web)"],"exampleFix":"# before\ndocker stats --filter label=app=web web1\n# after\ndocker stats $(docker ps -q --filter label=app=web)","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":["docker-cli","container","stats","filter","conflicting-flags"],"analyzedSha":"e9452d6e785f6e365712b9d71bd7517591773c86","analyzedAt":"2026-08-01T07:09:22.474Z","schemaVersion":2}