containers / podman

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

Podman remote windows cannot mount volume: invalid container path "/data", must be an absolute path #10900

Closed faitz closed 3 years ago

faitz commented 3 years ago

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

/kind bug

Description

Cannot create a container with mounted volume, podman is validating destination path using absolute path, on UNIX system absolute path always starts with a slash /, but on windows, it started with a drive letter. so podman always give an error Error: invalid container path "/data", must be an absolute path

Steps to reproduce the issue:

Create and run container using podman remote windows

podman run -it --rm -v /mnt/i/source:/data fedora bash

Describe the results you received:

Got an error:

Error: invalid container path "/data", must be an absolute path

Describe the results you expected:

container should be running and /mnt/i/soruce mounted to /data

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

Output of podman version:

Client:
Version:      3.2.1
API Version:  3.2.1
Go Version:   go1.15.11
Git Commit:   152952fe6b18581615c3efd1fafef2d8142738e8
Built:        Fri Jun 18 22:54:25 2021
OS/Arch:      windows/amd64

Server:
Version:      3.2.1
API Version:  3.2.1
Go Version:   go1.16.4
Built:        Wed Jul  7 11:32:49 2021
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.21.0
  cgroupControllers:
  - cpuset
  - cpu
  - cpuacct
  - blkio
  - memory
  - devices
  - freezer
  - net_cls
  - perf_event
  - net_prio
  - hugetlb
  - pids
  - rdma
  cgroupManager: systemd
  cgroupVersion: v1
  conmon:
    package: conmon-2.0.29-1.el8.3.7.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.29, commit: '
  cpus: 4
  distribution:
    distribution: '"centos"'
    version: "8"
  eventLogger: journald
  hostname: container.vbox
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 4.18.0-305.7.1.el8_4.x86_64
  linkmode: dynamic
  memFree: 7469297664
  memTotal: 8145641472
  ociRuntime:
    name: crun
    package: crun-0.20.1-1.el8.3.4.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 0.20.1
      commit: 0d42f1109fd73548f44b01b3e84d04a279e99d2e
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    exists: true
    path: /run/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: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 2218782720
  swapTotal: 2218782720
  uptime: 4m 42.67s
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - registry.centos.org
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 2
  runRoot: /var/run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 3.2.1
  Built: 1625632369
  BuiltTime: Wed Jul  7 00:32:49 2021
  GitCommit: ""
  GoVersion: go1.16.4
  OsArch: linux/amd64
  Version: 3.2.1

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

No

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

Podman server running on VirtualBox using Centos Stream 8

mheon commented 3 years ago

Theory: we're probably validating client-side, using the Go filepath library, which is using Windows path standards instead of Linux, so expecting drive letters and backslash separators. Easiest solution is probably to move the validation to the server.

github-actions[bot] commented 3 years ago

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

rhatdan commented 3 years ago

@flouthoc PTAL

flouthoc commented 3 years ago

@rhatdan Destination path inside containers should be always validated as *nixtype absolute path. So I think check should be fixed.

So its recommended to use path.IsAbs() instead of filtepath.IsAbs() for destination checks. Since filepath.IsAbs() will use path_windows on windows host but destination path inside the containers should always be of *nix type.

Reference: https://cs.opensource.google/go/go/+/refs/tags/go1.16.7:src/path/path.go;l=219 https://cs.opensource.google/go/go/+/refs/tags/go1.16.7:src/path/filepath/path_windows.go https://cs.opensource.google/go/go/+/refs/tags/go1.16.7:src/path/filepath/path_unix.go

flouthoc commented 3 years ago

but we should also move this to server side as @mheon suggested but above PR fixes the use case.

flouthoc commented 3 years ago

We can prefer as final fix https://github.com/containers/podman/pull/11231 i.e what @mheon suggested.

asbachb commented 2 years ago

Can someone double check if this is fixed in 3.4.4? I still get this error on windows (remote client) and linux (via TCP).

flouthoc commented 2 years ago

@asbachb Is your client and remote both on 3.4.4. Could you show the command and the error.

asbachb commented 2 years ago

@flouthoc

PS C:\dev\src\java\amadeus-bahn-jboss-migration\nps2> podman version
Client:
Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.16.8
Git Commit:   f6526ada1025c2e3f88745ba83b8b461ca659933
Built:        Wed Dec  8 22:14:28 2021
OS/Arch:      windows/amd64

Server:
Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.16.10
Built:        Tue Jan  1 01:00:00 1980
OS/Arch:      linux/amd64
PS C:\dev\tmp\podman-test> podman run --mount=type=bind,source=C:\dev\tmp\podman-test\hello.txt,destination=/tmp/hello.txt alpine cat
Error: invalid container path "\\tmp\\hello.txt", must be an absolute path
PS C:\dev\tmp\podman-test> podman run --mount=type=bind,source=C:\dev\tmp\podman-test\hello.txt,destination=/tmp/ alpine cat
Error: invalid container path "\\tmp", must be an absolute path
PS C:\dev\tmp\podman-test> podman run --mount=type=bind,source=C:\dev\tmp\podman-test\hello.txt,destination=/tmp alpine cat
Error: invalid container path "\\tmp", must be an absolute path
PS C:\dev\tmp\podman-test> podman run --mount=type=bind,source=C:\dev\tmp\podman-test\hello.txt,destination=/ alpine cat
Error: invalid container path "\\", must be an absolute path
PS C:\dev\tmp\podman-test> podman run --mount=type=bind,source=C:\dev\tmp\podman-test\hello.txt,destination=/ alpine cat
flouthoc commented 2 years ago

@asbachb What you are trying is bind mounting from a windows host into linux podman machine. This feature is currently not supported and more on mounting files from host to remote is being discussed here: https://github.com/containers/podman/issues/8016

asbachb commented 2 years ago

@flouthoc Ah thanks for clarification. I guess the error message was kind of confusing for me as it indicates a problem on guest side.