Skip to content

Fix docker compose ps to honor psFormat setting in .docker/config.json#13645

Open
maks2134 wants to merge 1 commit intodocker:mainfrom
maks2134:13643-ps-format-config-clean
Open

Fix docker compose ps to honor psFormat setting in .docker/config.json#13645
maks2134 wants to merge 1 commit intodocker:mainfrom
maks2134:13643-ps-format-config-clean

Conversation

@maks2134
Copy link

  • Change format flag default from "table" to empty string to allow config override
  • Add logic to use PsFormat from config when no format argument provided
  • Fall back to "table" format when neither PsFormat nor format arg is set
  • Add warning when both --format and --quiet flags are used
  • Add test to verify format flag default value

Fixes #13643

What I did

Related issue

(not mandatory) A picture of a cute animal, if possible in relation to what you did

- Change format flag default from "table" to empty string to allow config override
- Add logic to use PsFormat from config when no format argument provided
- Fall back to "table" format when neither PsFormat nor format arg is set
- Add warning when both --format and --quiet flags are used
- Add test to verify format flag default value

Fixes docker#13643

Signed-off-by: maks2134 <maks210306@yandex.by>
@maks2134 maks2134 requested a review from a team as a code owner March 18, 2026 16:00
@maks2134 maks2134 requested review from glours and ndeloof March 18, 2026 16:00
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution 🙏
This one need some changes to properly and transparently support psFormat setting
Can you also add more tests regarding the comment I made when changing or not the --format flag please?

Comment on lines +158 to +162
if len(opts.Format) == 0 {
opts.Format = "table"
} else if opts.Quiet {
_, _ = dockerCli.Err().Write([]byte("WARNING: Ignoring custom format, because both --format and --quiet are set.\n"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

With this changes users with psFormat in their config who runs docker compose ps -q would get a spurious warning.
We should only trigger this check when cmd.Flags().Changed("format") is true

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I would prefer we use fmt.Fprintln instead of Write like this
fmt.Fprintln(dockerCli.Err(), "WARNING: ...")

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.

'docker compose ps' not honoring 'psFormat' setting in '.docker/config.json'

2 participants