Skip to content

docker ps using psFormat in config that contains Size does not behave as expected #3632

@jswolf19

Description

@jswolf19

Description

I have created a config.json file in my .docker folder which specifies a psFormat which includes .Size.
When I execute docker ps, the SIZE column shows 0B. If I specify the same format on the command line, the size is shown as expected.

The logic for --format checks for size and modifies the Size option if the format includes size, but if --format is not set, it seems that a format that doesn't contain Size is assumed.

Steps to reproduce the issue:

  1. Create a config.json file with psFormat = "table {{.ID}}\t{{.RunningFor}}\t{{.Status}}\t{{.Size}}"
  2. Run docker ps

Describe the results you received:
Something similar to:

CONTAINER ID   CREATED        STATUS        SIZE
d367e8c585df   46 hours ago   Up 46 hours   0B
1a3eeef4e88b   5 days ago     Up 5 days     0B
b9fddd45560e   5 days ago     Up 5 days     0B
efd0485c7898   7 days ago     Up 7 days     0B
6be3e03c5351   8 days ago     Up 8 days     0B
...

Describe the results you expected:
Something similar to:

CONTAINER ID   CREATED        STATUS        SIZE
d367e8c585df   46 hours ago   Up 46 hours   0B (virtual 313MB)
1a3eeef4e88b   5 days ago     Up 5 days     257B (virtual 401MB)
b9fddd45560e   5 days ago     Up 5 days     0B (virtual 455MB)
efd0485c7898   7 days ago     Up 7 days     8.19kB (virtual 317MB)
6be3e03c5351   8 days ago     Up 8 days     8.19kB (virtual 313MB)
...

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:           20.10.12-ce
 API version:       1.41
 Go version:        go1.16.13
 Git commit:        459d0dfbbb51
 Built:             Mon Jan 17 12:00:00 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.12-ce
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.13
  Git commit:       459d0dfbbb51
  Built:            Mon Jan 17 12:00:00 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.3
  GitCommit:
 docker-init:
  Version:          0.1.5_catatonit
  GitCommit:

Output of docker info:

Client:
 Version:           20.10.12-ce
 API version:       1.41
 Go version:        go1.16.13
 Git commit:        459d0dfbbb51
 Built:             Mon Jan 17 12:00:00 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.12-ce
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.13
  Git commit:       459d0dfbbb51
  Built:            Mon Jan 17 12:00:00 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.12
  GitCommit:        7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc:
  Version:          1.0.3
  GitCommit:
 docker-init:
  Version:          0.1.5_catatonit
  GitCommit:
jon_s@LINUX-SERVER:~ > docker info
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 19
  Running: 19
  Paused: 0
  Stopped: 0
 Images: 223
 Server Version: 20.10.12-ce
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 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: io.containerd.runc.v2 io.containerd.runtime.v1.linux oci runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
 runc version:
 init version:
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.3.18-150300.59.54-default
 Operating System: openSUSE Leap 15.3
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 19.37GiB
 Name: LINUX-SERVER
 ID: RMKV:5FJ7:TQRJ:ENCG:3WK5:Y3ND:GYEQ:HJ36:4OSP:ROSX:6GB3:7FQJ
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):
OpenSuse Leap 15.3

docker                 | package | 20.10.12_ce-159.1 | x86_64 | Update repository with updates from SUSE Linux Enterprise 15
docker-bash-completion | package | 20.10.12_ce-159.1 | noarch | Update repository with updates from SUSE Linux Enterprise 15
zypper-docker          | package | 2.0.0-3.5.1       | x86_64 | Main Repository

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