Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

podman ps -a --format=json does not include image hash #5160

Closed
liewegas opened this issue Feb 10, 2020 · 9 comments · Fixed by #5223
Closed

podman ps -a --format=json does not include image hash #5160

liewegas opened this issue Feb 10, 2020 · 9 comments · Fixed by #5223
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@liewegas
Copy link

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind feature

Description

The podman inspect output includes the both the Image property (the hash) and ImageName property (container name). podman ps --format=json output does not include the hash. For our application (ceph), that means we need to run inspect on every running container to get this information and build a host inventory.

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

Output of podman version:

1.7.0

Output of podman info --debug:

debug:
  compiler: gc
  git commit: ""
  go version: go1.13.5
  podman version: 1.7.0
host:
  BuildahVersion: 1.12.0
  CgroupVersion: v2
  Conmon:
    package: conmon-2.0.9-2.fc31.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.9, commit: 7d46f3e7711aa3578488284ae2f98b447658f086'
  Distribution:
    distribution: fedora
    version: "31"
  MemFree: 37882519552
  MemTotal: 202800291840
  OCIRuntime:
    name: crun
    package: crun-0.10.6-1.fc31.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.10.6
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  SwapFree: 23485739008
  SwapTotal: 24008192000
  arch: amd64
  cpus: 32
  eventlogger: journald
  hostname: gnit
  kernel: 5.3.16-300.fc31.x86_64
  os: linux
  rootless: false
  uptime: 318h 53m 57.5s (Approximately 13.25 days)
registries:
  search:
  - docker.io
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - registry.centos.org
  - quay.io
store:
  ConfigFile: /etc/containers/storage.conf
  ContainerStore:
    number: 13
  GraphDriverName: overlay
  GraphOptions:
    overlay.mountopt: nodev,metacopy=on
  GraphRoot: /var/lib/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "true"
  ImageStore:
    number: 15
  RunRoot: /var/run/containers/storage
  VolumePath: /var/lib/containers/storage/volumes

Package info (e.g. output of rpm -q podman or apt list podman):

podman-1.7.0-2.fc31.x86_64
@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 10, 2020
@baude
Copy link
Member

baude commented Feb 11, 2020

@liewegas thanks for the report ... im not sure i understand what you are asking for. you want another field that has the hash or ? are you comparing us to docker?

@vrothberg
Copy link
Member

vrothberg commented Feb 13, 2020

Note that podman inspect does not contain the hash (i.e., the sha256 digest) of an image but the image ID which is also included in podman ps:

$ podman ps --format=json            
[                                                    
     {                                               
          "ID": "694456a0f847",                      
          "Image": "docker.io/library/alpine:latest",
....

The difference is that ps prints the short digest, while inspect shows the full digest:

"Image": "e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a",
"ImageName": "docker.io/library/alpine:latest",

@liewegas, can elaborate a bit more which data you desire?

@mheon
Copy link
Member

mheon commented Feb 13, 2020

Isn't ID in ps the container ID?

@vrothberg
Copy link
Member

Isn't ID in ps the container ID?

Must have been a lack of coffee :^) Yes, that's the container ID.

Inspect uses "Image" as the ID, and "ImageName" as the reference. Ps is using "Image" as the reference.

Curiously:

root@nebuchadnezzar valentin # docker ps --format "{{.ID}} {{.Image}}"
a24b256a66ac alpine

While Docker docs claim Image as the ID...

It would still be helpful to fully understand @liewegas's use case.

@liewegas
Copy link
Author

I'm trying to build an inventory of running ceph containers on the host that includes

  • container id
  • image name
  • image id (hash)

and do it quickly. Right now that requires running podman inspect on every container, which makes this inventory take many seconds overall. If the podman ps included the image hash, then it would have everything I need and (I'm hoping) still take the <200ms it does now.

@vrothberg
Copy link
Member

I think we can add that to the output. But note that the ID is not a hash (as the image digest) but just a unique ID.

@rhatdan
Copy link
Member

rhatdan commented Feb 14, 2020

Is there a way to customize the podman ps output, similar to podman top?

@vrothberg
Copy link
Member

Is there a way to customize the podman ps output, similar to podman top?

Yes, with --format.

@vrothberg
Copy link
Member

I opened #5223

vrothberg added a commit to vrothberg/libpod that referenced this issue Feb 17, 2020
Support printing image IDs via `--format "{{.ImageID}}"`.

Fixes: containers#5160
Signed-off-by: Valentin Rothberg <[email protected]>
snj33v pushed a commit to snj33v/libpod that referenced this issue May 31, 2020
Support printing image IDs via `--format "{{.ImageID}}"`.

Fixes: containers#5160
Signed-off-by: Valentin Rothberg <[email protected]>
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants