-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Hi,
I tried to change the default output table of the docker compose ps command to match my docker ps output.
Running
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"creates the table I want. Setting the psFormat key in my .docker/config.json
{
"psFormat": "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"
}results in docker ps showing this table by default, as desired.
Using the same format argument on docker compose ps
docker compose ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"results in the correct table.
But docker compose ps does not use this setting as its default.
When looking for the correct key for my .docker/config.json I found that in /cmd/compose/ps.go on Line 156
Lines 155 to 157 in e8c2143
| if opts.Format == "" { | |
| opts.Format = dockerCli.ConfigFile().PsFormat | |
| } |
docker compose ps checks for the same psFormat key in the config, but it is only applied when --format is set to an empty sting:
This means
docker compose ps --format ""results in the same output as
docker compose ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"but not
docker compose psMaybe the check in L155 should use the same code as the docker cli for determining the format:
format := options.format
if len(format) == 0 {
format = task.DefaultFormat(dockerCLI.ConfigFile(), options.quiet)
}