containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
23.57k stars 2.4k forks source link

Container creation expects field "Destination" under "Mounts", API doc says "Target" #13092

Open hllizi opened 2 years ago

hllizi commented 2 years ago

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

/kind bug

Description

The Attribute for specifying a mount destination when creating a container appears to be "Destination" in the REST API and not "Target" (as in the cli).

Steps to reproduce the issue:

  1. podman pull hello-world

  2. curl http://localhost:8080/v3.4.2/libpod/containers/create -H "Content-Type: application/json" -d '{"Image": "hello-world-image-id", "mounts": [{"Type": "bind", "Source": "some-file", "Target": "/test", "BindOptions": {"NonRecursive": true}}]}' (obviously, with the podman service running on TCP port 8080)

Describe the results you received: {"cause":"container directory cannot be empty","message":"container directory cannot be empty","response":500}

Describe the results you expected: Properly built container.

Additional information you deem important (e.g. issue happens only occasionally): With podman 3.1.2, no error response was given and a container was built, but the problem was the same at heart: podman inspect container-id would show an empty string as the value of "Mounts.Destination".

Output of podman version:

podman version 3.4.2

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.23.1
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: Unknown
    path: /nix/store/vydh4jhks3x3xnfs24ci5jp3gahnlvqd-conmon-2.0.30/bin/conmon
    version: 'conmon version 2.0.30, commit: '
  cpus: 4
  distribution:
    codename: porcupine
    distribution: nixos
    version: "21.11"
  eventLogger: journald
  hostname: weltraum
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 100
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1001
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 5.10.93
  linkmode: dynamic
  logDriver: journald
  memFree: 1856757760
  memTotal: 8217649152
  ociRuntime:
    name: crun
    package: Unknown
    path: /nix/store/ii3wd9s84i28kbf02p29hn62xdyxc82a-crun-1.3/bin/crun
    version: |-
      crun version 1.3
      commit: 1.3
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  remoteSocket:
    path: /run/user/1001/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_AUDIT_WRITE,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_MKNOD,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: ""
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /nix/store/9qis38vxi5r0ww277qvq5q4f46pbn616-slirp4netns-1.1.12/bin/slirp4netns
    package: Unknown
    version: |-
      slirp4netns version 1.1.12
      commit: 7a104a101aa3278a2152351a082a6df71f57c9a3
      libslirp: 4.6.1
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.2
  swapFree: 8589930496
  swapTotal: 8589930496
  uptime: 1h 42m 26.63s (Approximately 0.04 days)
plugins:
  log:
  - k8s-file
  - none
  - journald
  network:
  - bridge
  - macvlan
  volume:
  - local
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /home/dlahm/.config/containers/storage.conf
  containerStore:
    number: 7
    paused: 0
    running: 0
    stopped: 7
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /nix/store/jnwfa8l77kwpvhx6299gzix5bbfdgmah-fuse-overlayfs-1.7.1/bin/fuse-overlayfs
      Package: Unknown
      Version: |-
        fuse-overlayfs: version 1.7.1
        FUSE library version 3.10.5
        using FUSE kernel interface version 7.31
  graphRoot: /home/dlahm/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 2
  runRoot: /run/user/1001/containers
  volumePath: /home/dlahm/.local/share/containers/storage/volumes
version:
  APIVersion: 3.4.2
  Built: 315532800
  BuiltTime: Tue Jan  1 01:00:00 1980
  GitCommit: ""
  GoVersion: go1.16.9
  OsArch: linux/amd64
  Version: 3.4.2

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

most recent package from nixos-21.11

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

openshift-ci[bot] commented 2 years ago

@hllizi: The label(s) kind/bu cannot be applied, because the repository doesn't have them.

In response to [this](https://github.com/containers/podman/issues/13092): >**Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)** > >/kind bu > >**Description** > >The Attribute for specifying a mount destination when creating a container appears to be "Destination" in the REST API and not "Target" (as in the cli). > >**Steps to reproduce the issue:** > >1. podman pull hello-world > >2. curl http://localhost:8080/v3.4.2/libpod/containers/create -H "Content-Type: application/json" -d '{"Image": "", "mounts": [{"Type": "bind", "Source": "", "Target": "/test", "BindOptions": {"NonRecursive": true}}]}' (obviously, with the podman service running on TCP port 8080) > >**Describe the results you received:** >{"cause":"container directory cannot be empty","message":"container directory cannot be empty","response":500} > >**Describe the results you expected:** >Properly built container. > >**Additional information you deem important (e.g. issue happens only occasionally):** >With podman 3.1.2, no error response was given and a container was built, but the problem was the same at heart: podman inspect would show an empty string as the value of "Mounts.Destination". > >**Output of `podman version`:** > >``` >podman version 3.4.2 >``` > >**Output of `podman info --debug`:** > >``` >host: > arch: amd64 > buildahVersion: 1.23.1 > cgroupControllers: > - memory > - pids > cgroupManager: systemd > cgroupVersion: v2 > conmon: > package: Unknown > path: /nix/store/vydh4jhks3x3xnfs24ci5jp3gahnlvqd-conmon-2.0.30/bin/conmon > version: 'conmon version 2.0.30, commit: ' > cpus: 4 > distribution: > codename: porcupine > distribution: nixos > version: "21.11" > eventLogger: journald > hostname: weltraum > idMappings: > gidmap: > - container_id: 0 > host_id: 100 > size: 1 > - container_id: 1 > host_id: 100000 > size: 65536 > uidmap: > - container_id: 0 > host_id: 1001 > size: 1 > - container_id: 1 > host_id: 100000 > size: 65536 > kernel: 5.10.93 > linkmode: dynamic > logDriver: journald > memFree: 1856757760 > memTotal: 8217649152 > ociRuntime: > name: crun > package: Unknown > path: /nix/store/ii3wd9s84i28kbf02p29hn62xdyxc82a-crun-1.3/bin/crun > version: |- > crun version 1.3 > commit: 1.3 > spec: 1.0.0 > +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL > os: linux > remoteSocket: > path: /run/user/1001/podman/podman.sock > security: > apparmorEnabled: false > capabilities: CAP_AUDIT_WRITE,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_MKNOD,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT > rootless: true > seccompEnabled: true > seccompProfilePath: "" > selinuxEnabled: false > serviceIsRemote: false > slirp4netns: > executable: /nix/store/9qis38vxi5r0ww277qvq5q4f46pbn616-slirp4netns-1.1.12/bin/slirp4netns > package: Unknown > version: |- > slirp4netns version 1.1.12 > commit: 7a104a101aa3278a2152351a082a6df71f57c9a3 > libslirp: 4.6.1 > SLIRP_CONFIG_VERSION_MAX: 3 > libseccomp: 2.5.2 > swapFree: 8589930496 > swapTotal: 8589930496 > uptime: 1h 42m 26.63s (Approximately 0.04 days) >plugins: > log: > - k8s-file > - none > - journald > network: > - bridge > - macvlan > volume: > - local >registries: > search: > - docker.io > - quay.io >store: > configFile: /home/dlahm/.config/containers/storage.conf > containerStore: > number: 7 > paused: 0 > running: 0 > stopped: 7 > graphDriverName: overlay > graphOptions: > overlay.mount_program: > Executable: /nix/store/jnwfa8l77kwpvhx6299gzix5bbfdgmah-fuse-overlayfs-1.7.1/bin/fuse-overlayfs > Package: Unknown > Version: |- > fuse-overlayfs: version 1.7.1 > FUSE library version 3.10.5 > using FUSE kernel interface version 7.31 > graphRoot: /home/dlahm/.local/share/containers/storage > graphStatus: > Backing Filesystem: extfs > Native Overlay Diff: "false" > Supports d_type: "true" > Using metacopy: "false" > imageStore: > number: 2 > runRoot: /run/user/1001/containers > volumePath: /home/dlahm/.local/share/containers/storage/volumes >version: > APIVersion: 3.4.2 > Built: 315532800 > BuiltTime: Tue Jan 1 01:00:00 1980 > GitCommit: "" > GoVersion: go1.16.9 > OsArch: linux/amd64 > Version: 3.4.2 > >``` > >**Package info (e.g. output of `rpm -q podman` or `apt list podman`):** > >``` >most recent package from nixos-21.11 >``` > >**Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)** > > >Yes > Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
rhatdan commented 2 years ago

@jwhonce @baude PTAL

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

flouthoc commented 2 years ago

This looks like a swagger or go-swagger issue to me, it should resolve type for Mount from runtime-spec however it resolves types from docker/api/types/mount/mount.go which is not even part of struct.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

p0da commented 2 years ago

Also ran into the same exact issue, took a while to figure it out. Seems like the API docs may need some work.

github-actions[bot] commented 2 years ago

A friendly reminder that this issue had no activity for 30 days.

sshnaidm commented 1 year ago

Took me a while to find it out, only google search lead me here. Really confusing to have non reliable API docs.

rhatdan commented 1 year ago

Interested in opening a PR to clean them up?

sshnaidm commented 1 year ago

Sure, will do

lacikawiz commented 1 year ago

The documentation still has this error.

ev-wilt commented 4 months ago

This still appears to be an issue.

rhatdan commented 4 months ago

Care to open a PR?