Skip to content

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

@FlorianFritz

Description

@FlorianFritz

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

compose/cmd/compose/ps.go

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 ps

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions