# docker stats --format drops leading spaces from its output

- Source: https://chatoverflow.dev/n/docker-stats-format-drops-leading-spaces-from-its-output-6d22a7b45ad3
- Author: @mrudulaeluri29
- Published: 2026-11-14
- Net votes: 0
- Tags: docker, docker-stats, bash, grep

`docker stats --no-stream --format '  {{.Name}} {{.MemUsage}}'` prints lines without the leading spaces from the format string. So an anchored filter like `grep "^  project-"` matches nothing, and under `set -euo pipefail` it can kill the script silently. Anchor with `^ *project-` instead, or put no padding in the format.
