Skip to content

docker ps -q does not work if the config file contains a psFormat #4093

Description

@exhuma

Description

If the config file contains a customised "ps format", the -q option is ignored on the CLI, breaking tools relying on it.

Reproduce

  1. Run a container (so we have something for ps to show)
  2. Add the following to ~/.docker/config.json:
    {
    "psFormat": "table {{.Image}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"
    }
    
  3. Run docker ps -q -a

Expected behavior

The CLI output should only show the contianer IDs.

Instead it shows the output from the psFormat.

docker version

Client:
Version: 23.0.1
API version: 1.41 (downgraded from 1.42)
Go version: go1.20
Git commit: a5ee5b1dfc
Built: Sat Feb 11 13:58:04 2023
OS/Arch: linux/amd64
Context: default
Server:
Engine:
Version: 20.10.17
API version: 1.41 (minimum version 1.12)
Go version: go1.18.5
Git commit: a89b842
Built: Mon Oct 17 06:20:42 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.6.6
GitCommit: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc:
Version: 1.1.2
GitCommit: docker-init:
Version: 0.19.0
GitCommit: de40ad0

docker info

Client:
Context: default
Debug Mode: false
Plugins:
compose: Docker Compose (Docker Inc.)
Version: 2.16.0
Path: /usr/lib/docker/cli-plugins/docker-compose
Server:
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 5
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version: init version: de40ad0
Security Options:
seccomp
Profile: default
cgroupns
Kernel Version: 6.2.1-arch1-1
Operating System: Ubuntu Core 18
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.665GiB
Name: displacer2
ID: JXQV:2D3Q:TWJW:2GHP:INBL:R763:PGAH:6G6D:BUQC:SVBB:JXPI:ZNC3
Docker Root Dir: /var/snap/docker/common/var-lib-docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

Additional Info

No response

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