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
|
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
Maybe 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)
}
https://github.com/docker/cli/blob/743c385f784e10c9cd29a2800fb72901bec053d4/cli/command/node/ps.go#L87-L90
Hi,
I tried to change the default output table of the
docker compose pscommand to match mydocker psoutput.Running
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"creates the table I want. Setting the
psFormatkey in my.docker/config.json{ "psFormat": "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" }results in
docker psshowing this table by default, as desired.Using the same format argument on
docker compose psdocker compose ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"results in the correct table.
But
docker compose psdoes not use this setting as its default.When looking for the correct key for my
.docker/config.jsonI found that in /cmd/compose/ps.go on Line 156compose/cmd/compose/ps.go
Lines 155 to 157 in e8c2143
docker compose pschecks for the samepsFormatkey in the config, but it is only applied when--formatis 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
Maybe the check in L155 should use the same code as the docker cli for determining the format:
https://github.com/docker/cli/blob/743c385f784e10c9cd29a2800fb72901bec053d4/cli/command/node/ps.go#L87-L90