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

[Bug]: JSON format output is not matching Docker JSON output format #17229

Closed
evanshortiss opened this issue Jan 26, 2023 · 14 comments
Closed

[Bug]: JSON format output is not matching Docker JSON output format #17229

evanshortiss opened this issue Jan 26, 2023 · 14 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. remote Problem is in podman-remote

Comments

@evanshortiss
Copy link

evanshortiss commented Jan 26, 2023

Issue Description

Output from docker image ls --format {{json .}} is line delimited JSON objects, but Podman output is a JSON array. I ran into this trying to use Podman with the VSCode Docker extension (issue microsoft/vscode-docker#3812)

Steps to reproduce the issue

Steps to reproduce the issue (I am on macOS, but don't think that matters):

  1. Pull an image, e.g: podman pull registry.access.redhat.com/ubi8/openjdk-17:1.14
  2. List images in JSON format using Podman CLI: podman image ls --filter dangling=false --no-trunc --format {{json .}}
  3. List images in JSON format using Docker CLI: DOCKER_HOST=unix:///Users/$USER/.local/share/containers/podman/machine/podman-machine-default/podman.sock docker image ls --filter dangling=false --no-trunc --format {{json .}}

Note the difference in the output format.

Describe the results you received

Output examples for both CLIs are included below:

Docker

docker image ls --filter dangling=false --no-trunc --format {{json .}}
{"Containers":"N/A","CreatedAt":"2023-01-18 02:19:32 -0800 PST","CreatedSince":"7 days ago","Digest":"\u003cnone\u003e","ID":"sha256:25b4f3c19d92ecdf2543660323e28c486c3bd3d163eb33f36284fdc390151273","Repository":"registry.access.redhat.com/ubi8/openjdk-17","SharedSize":"N/A","Size":"420MB","Tag":"1.14","UniqueSize":"N/A","VirtualSize":"419.6MB"}
{"Containers":"N/A","CreatedAt":"2023-01-17 13:26:02 -0800 PST","CreatedSince":"8 days ago","Digest":"\u003cnone\u003e","ID":"sha256:2030918f10e8371bb55240da2bf0b8dff52488c9ffaabdd164abd1052479e8e3","Repository":"redis","SharedSize":"N/A","Size":"30.3MB","Tag":"7-alpine","UniqueSize":"N/A","VirtualSize":"30.31MB"}
{"Containers":"N/A","CreatedAt":"2022-10-29 10:46:44 -0700 PDT","CreatedSince":"2 months ago","Digest":"\u003cnone\u003e","ID":"sha256:d3cc09b059e06f72a1f1351b0a003e6c490d4e4f80fc778befde2c7ac6e804d4","Repository":"quay.io/strimzi/kafka","SharedSize":"N/A","Size":"639MB","Tag":"0.32.0-kafka-3.3.1","UniqueSize":"N/A","VirtualSize":"639.2MB"}
{"Containers":"N/A","CreatedAt":"2022-07-28 07:12:30 -0700 PDT","CreatedSince":"6 months ago","Digest":"\u003cnone\u003e","ID":"sha256:5d28cedc492d64d21c11814d84d9d41566f07023b9c95245e163b05acfcb7172","Repository":"testcontainers/ryuk","SharedSize":"N/A","Size":"11.5MB","Tag":"0.3.4","UniqueSize":"N/A","VirtualSize":"11.48MB"}
{"Containers":"N/A","CreatedAt":"2021-11-03 15:51:58 -0700 PDT","CreatedSince":"14 months ago","Digest":"\u003cnone\u003e","ID":"sha256:5d0cbea9916f4e058267d6c2085aaa11fa75fe4780d735adce459bc79a6c40f1","Repository":"antora/antora","SharedSize":"N/A","Size":"95.7MB","Tag":"2.3.4","UniqueSize":"N/A","VirtualSize":"95.65MB"}

Podman

podman image ls --filter dangling=false --no-trunc --format {{json .}}
[
    {
        "Id": "5f3b9471a65d9cbe70f41f5e46a7f2c8672709556e444ed148d023f89ec74ca7",
        "ParentId": "fedee2f8f2089adbe996e19e802797df236ff4ad9c674d4e5f4e011ca7795ab1",
        "RepoTags": null,
        "RepoDigests": [
            "registry.access.redhat.com/ubi8/openjdk-17@sha256:28f11d44f9613cff70108bdb4083aa46cad0faff199758f761bf62a34cb50e8a",
            "registry.access.redhat.com/ubi8/openjdk-17@sha256:6b536eec3bbf1e795d61a49ec7b5a80687fb5890d7e961ae0ddab672b8aaed54"
        ],
        "Size": 423383289,
        "SharedSize": 0,
        "VirtualSize": 423383289,
        "Labels": {
            "architecture": "arm64",
            "build-date": "2022-10-11T19:59:01.009662",
            "com.redhat.build-host": "arm-003.osbs.prod.upshift.rdu2.redhat.com",
            "com.redhat.component": "openjdk-17-ubi8-container",
            "com.redhat.license_terms": "https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI",
            "description": "Source To Image (S2I) image for Red Hat OpenShift providing OpenJDK 17",
        },
        "Containers": 0,
        "Names": [
            "registry.access.redhat.com/ubi8/openjdk-17:1.14"
        ],
        "Digest": "sha256:28f11d44f9613cff70108bdb4083aa46cad0faff199758f761bf62a34cb50e8a",
        "History": [
            "registry.access.redhat.com/ubi8/openjdk-17:1.14"
        ],
        "Created": 1665520470,
        "CreatedAt": "2022-10-11T20:34:30Z"
    }
]

Describe the results you expected

Expected Podman CLI output to match Docker CLI.

podman info output

host:
  arch: arm64
  buildahVersion: 1.28.0
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.5-1.fc37.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.5, commit: '
  cpuUtilization:
    idlePercent: 99.8
    systemPercent: 0.09
    userPercent: 0.11
  cpus: 1
  distribution:
    distribution: fedora
    variant: coreos
    version: "37"
  eventLogger: journald
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
    uidmap:
    - container_id: 0
      host_id: 501
      size: 1
    - container_id: 1
      host_id: 100000
      size: 1000000
  kernel: 6.0.18-300.fc37.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 1578745856
  memTotal: 2049859584
  networkBackend: netavark
  ociRuntime:
    name: crun
    package: crun-1.7.2-3.fc37.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.7.2
      commit: 0356bf4aff9a133d655dc13b1d9ac9424706cac4
      rundir: /run/user/501/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/user/501/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.0-8.fc37.aarch64
    version: |-
      slirp4netns version 1.2.0
      commit: 656041d45cfca7a4176f6b7eed9e4fe6c11e8383
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 0
  swapTotal: 0
  uptime: 82h 5m 29.00s (Approximately 3.42 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /var/home/core/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 0
    stopped: 2
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/home/core/.local/share/containers/storage
  graphRootAllocated: 106825756672
  graphRootUsed: 9542553600
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 76
  runRoot: /run/user/501/containers
  volumePath: /var/home/core/.local/share/containers/storage/volumes
version:
  APIVersion: 4.3.1
  Built: 1668178831
  BuiltTime: Fri Nov 11 07:00:31 2022
  GitCommit: ""
  GoVersion: go1.19.2
  Os: linux
  OsArch: linux/arm64
  Version: 4.3.1

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

N/A

Additional information

N/A

@evanshortiss evanshortiss added the kind/bug Categorizes issue or PR as related to a bug. label Jan 26, 2023
@github-actions github-actions bot added the remote Problem is in podman-remote label Jan 26, 2023
@evanshortiss
Copy link
Author

I should add, I understand this might not be a bug and by design but I didn't see it raised when I did a quick search.

@rhatdan
Copy link
Member

rhatdan commented Jan 26, 2023

I have a feeling this might be difficult for us to fix at this point, since we could break users of Podman. @mheon WDYT?

@mheon
Copy link
Member

mheon commented Jan 26, 2023

We can do the Docker-compat HTTP API easily enough. It's a lot harder to justify breaking the CLI version. Might be a good 5.0 breaking change?

@Luap99
Copy link
Member

Luap99 commented Jan 26, 2023

I already fixed this for 4.4, #16446

@Luap99 Luap99 closed this as completed Jan 26, 2023
@evanshortiss
Copy link
Author

@Luap99 thank you! I didn't spot that when I searched 🎉

@JustinGrote
Copy link

@Luap99 I tried the 4.4 dev from the latest commit and it still doesn't work for me. Reverting to older docker extension 1.22.2 fixes it.

image

@evanshortiss
Copy link
Author

@JustinGrote thanks for the reminder on this. I tested too, and found that it didn't work because the keys returned in 4.4 aren't consistent with those from Docker's CLI, e.g Id vs ID. The VSCode plugin doesn't like that. Interesting that the older extension works.

@bwateratmsft
Copy link

bwateratmsft commented Feb 1, 2023

The older Docker extension version (1.22.x and below) uses the Docker (or in this case, Podman) HTTP daemon for most things. Podman's HTTP daemon more closely matches Docker's, compared to their respective CLIs. With extension version 1.23+, we're exclusively using the CLI to communicate, hence the greater sensitivity to the differences.

@rhatdan
Copy link
Member

rhatdan commented Feb 2, 2023

If we output with ID and Id, would it work?

@baude
Copy link
Member

baude commented Feb 2, 2023

@evanshortiss any chance you all of the problems? i'm wondering if we could make the plugin tolerant of case sensitivity?

@bwateratmsft
Copy link

bwateratmsft commented Feb 2, 2023

I don't think any changes to Podman are necessary. We (Docker extension) are working on an abstraction layer to deal gracefully with different container runtimes.

@baude
Copy link
Member

baude commented Feb 2, 2023

@bwateratmsft that's awesome! thanks so much! If there is something you need us to do to support you, please just ask. you can also find us on IRC at libera #podman

@deboer-tim
Copy link

@bwateratmsft any update, or is there an issue in the docker extension we could follow (I couldn't find one)?

@bwateratmsft
Copy link

@deboer-tim we're tracking it in microsoft/vscode-docker#3241 / microsoft/vscode-docker#3411

@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 Aug 31, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. remote Problem is in podman-remote
Projects
None yet
Development

No branches or pull requests

8 participants