Skip to content

[BUG] Podman REST API return a list of containers with partial/missing "Mounts" attribute values #24878

Open
@D3vil0p3r

Description

@D3vil0p3r

Issue Description

Podman REST API container list returns a list of containers with partial/missing Mounts attribute values.

Steps to reproduce the issue

Start podman daemon:

systemctl --user start podman

To simplify the reproduction, let's use Podman py:

import podman
from podman import PodmanClient

client = podman.from_env()
client.ping()
image = client.images.pull('docker.io/athenaos/base:latest')  
docker_create_function = client.containers.create
docker_args = {"image": image ,
               "name": "exegol-default",
               "mounts": [
                    {'target': '/opt/resources', 'source': '/home/athena/Desktop', 'type': 'bind'},
                    {'target': '/workspaces', 'source': '/home/athena/Documents', 'type': 'bind'}
                ]}

container = docker_create_function(**docker_args)
print(container.attrs.get("Mounts", []))

print("Now use client.containers.list:")
docker_containers = client.containers.list(all=True, filters={"name": "exegol-"})

for container in docker_containers:
    print(container.attrs.get("Mounts", []))

Run this script. It will create a exegol-default container with different mounts elements.

One note: when the container is created, the container attribute mounts has the right values. When the container is listed (so when the /containers/json API is invoked), no.

Then, enable API service:

podman system service tcp:localhost:8080 --time=0 &

and run:

curl -k http://localhost:8080/v4.0.0/libpod/containers/json?all=true | jq

It will return only target info of mounts, instead of other information:

...
    "Labels": null,
    "Mounts": [
      "/opt/resources",
      "/workspaces"
    ],
    "Names": [
      "exegol-default"
    ],
...

Describe the results you received

...
    "Labels": null,
    "Mounts": [
      "/opt/resources",
      "/workspaces"
    ],
    "Names": [
      "exegol-default"
    ],
...

Describe the results you expected

I expect that Podman API return all the elements of Mounts, so not only target but also source, type and so on. I expect a result as occurs by docker API when running:

curl --cacert ca.pem --cert client-cert.pem --key client-key.pem https://localhost:1234/containers/json?all=true | jq

By docker API the output is correct:

...
    "Mounts": [
      {
        "Type": "bind",
        "Source": "/home/athena/Exegol/exegol-resources",
        "Destination": "/opt/resources",
        "Mode": "",
        "RW": true,
        "Propagation": "rprivate"
      },
      {
        "Type": "bind",
        "Source": "/home/athena",
        "Destination": "/workspaces",
        "Mode": "",
        "RW": true,
        "Propagation": "rprivate"
      }
    ]
...

podman info output

host:
  arch: amd64
  buildahVersion: 1.38.0
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-1:2.1.12-1
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: e8896631295ccb0bfdda4284f1751be19b483264'
  cpuUtilization:
    idlePercent: 82.38
    systemPercent: 6.71
    userPercent: 10.91
  cpus: 4
  databaseBackend: sqlite
  distribution:
    distribution: athena
    version: Rolling release
  eventLogger: journald
  freeLocks: 2047
  hostname: athenaos
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.6.65-1-lts
  linkmode: dynamic
  logDriver: journald
  memFree: 264495104
  memTotal: 3966132224
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.13.1-1
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.13.1
    package: netavark-1.13.1-1
    path: /usr/lib/podman/netavark
    version: netavark 1.13.1
  ociRuntime:
    name: runc
    package: runc-1.2.3-1
    path: /usr/bin/runc
    version: |-
      runc version 1.2.3
      spec: 1.2.0
      go: go1.23.4
      libseccomp: 2.5.5
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-2024_11_27.c0fbc7e-1
    version: |
      pasta 2024_11_27.c0fbc7e
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  rootlessNetworkCmd: pasta
  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: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 6514012160
  swapTotal: 8053059584
  uptime: 7h 45m 8.00s (Approximately 0.29 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/athena/.config/containers/storage.conf
  containerStore:
    number: 1
    paused: 0
    running: 0
    stopped: 1
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/athena/.local/share/containers/storage
  graphRootAllocated: 631544741888
  graphRootUsed: 30339878912
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 3
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/athena/.local/share/containers/storage/volumes
version:
  APIVersion: 5.3.1
  Built: 1732225906
  BuiltTime: Thu Nov 21 22:51:46 2024
  GitCommit: 4cbdfde5d862dcdbe450c0f1d76ad75360f67a3c
  GoVersion: go1.23.3
  Os: linux
  OsArch: linux/amd64
  Version: 5.3.1

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

Arch Linux

Additional information

Initial issue reported to containers/podman-py#488

Metadata

Metadata

Assignees

No one assigned

    Labels

    HTTP APIBug is in RESTful APIkind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions