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 run cannot mount volume named with single character on windows #25218

Open
axel7083 opened this issue Feb 4, 2025 · 1 comment · May be fixed by #25323
Open

podman run cannot mount volume named with single character on windows #25218

axel7083 opened this issue Feb 4, 2025 · 1 comment · May be fixed by #25323
Labels
kind/bug Categorizes issue or PR as related to a bug. remote Problem is in podman-remote windows issue/bug on Windows

Comments

@axel7083
Copy link

axel7083 commented Feb 4, 2025

Issue Description

When trying to mount a volume which has a name which is a single character on windows, ( e.g. a, b, c etc.) an error is throwed.

Deep dive

On windows, the parsing of the volume argument is a bit tricky.

  1. It starts here, in our example volumeFlag = ["a:/mnt/home"]

volumeMounts, volumeVolumes, overlayVolumes, err := specgen.GenVolumeMounts(volumeFlag)

  1. For each volume flag, we try to split it in 3 part [[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]

func SplitVolumeString(vol string) []string {

  1. But windows... amazing windows, absolute path have a drive letter (E.g. C:/hello/world) and the following code is responsible of checking if it is an absolute path

if hasWinDriveScheme(vol, n) {
first := parts[0] + ":" + parts[1]
parts = parts[1:]
parts[0] = first
}

  1. Deep dive into hasWinDriveScheme

func hasWinDriveScheme(path string, start int) bool {
if len(path) < start+2 || path[start+1] != ':' {
return false
}
drive := rune(path[start])
return drive < unicode.MaxASCII && unicode.IsLetter(drive)
}

In our example, path = "a:/mnt/home", start = 0.

  • len(path) < start+2 = false
  • path[start+1] != ':' = false (problematic, it is confusing the colon separating the driver letter with the separator of the volume and container path

The last part is checking if the letter is a driver letter accepted value.

Steps to reproduce the issue

Run the following on windows

$: podman create volume a
a
$: podman run -v a:/mnt/ hello-world
Error: invalid container path "a:/mnt", must be an absolute path

Describe the results you received

On windows, I am getting the following error

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

Describe the results you expected

Volume to be mounted.

podman info output

host:
  arch: amd64
  buildahVersion: 1.38.0
  cgroupControllers:
  - cpuset
  - cpu
  - cpuacct
  - blkio
  - memory
  - devices
  - freezer
  - net_cls
  - perf_event
  - net_prio
  - hugetlb
  - pids
  - rdma
  - misc
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: conmon-2.1.12-2.fc40.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: '
  cpuUtilization:
    idlePercent: 99.4
    systemPercent: 0.39
    userPercent: 0.21
  cpus: 12
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "40"
  eventLogger: journald
  freeLocks: 2034
  hostname: Axel-Fix
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.15.167.4-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 23875559424
  memTotal: 25204797440
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.13.1-1.fc40.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.13.1
    package: netavark-1.13.1-1.fc40.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.13.1
  ociRuntime:
    name: crun
    package: crun-1.19.1-1.fc40.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.19.1
      commit: 3e32a70c93f5aa5fea69b50256cca7fd4aa23c80
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20241211.g09478d5-1.fc40.x86_64
    version: |
      pasta 0^20241211.g09478d5-1.fc40.x86_64
      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: unix:///run/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: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 6442450944
  swapTotal: 6442450944
  uptime: 0h 9m 49.00s
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 5
    paused: 0
    running: 0
    stopped: 5
  graphDriverName: overlay
  graphOptions:
    overlay.imagestore: /usr/lib/containers/storage
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 1081101176832
  graphRootUsed: 19998404608
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 110
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.3.1
  Built: 1732147200
  BuiltTime: Thu Nov 21 01:00:00 2024
  GitCommit: ""
  GoVersion: go1.22.7
  Os: linux
  OsArch: linux/amd64
  Version: 5.3.1

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

N/A

Additional information

N/A

@axel7083 axel7083 added the kind/bug Categorizes issue or PR as related to a bug. label Feb 4, 2025
@github-actions github-actions bot added the remote Problem is in podman-remote label Feb 4, 2025
@Luap99 Luap99 added the windows issue/bug on Windows label Feb 4, 2025
@l0rd
Copy link
Member

l0rd commented Feb 14, 2025

Nice catch @axel7083. A small note: in the description, you use the command podman create volume, but you probably meant podman volume create.

Are you going to submit a PR for this? Considering the analysis you have already done, it should not be hard. If you do, you want to start by adding a new test in machine e2e volumes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. remote Problem is in podman-remote windows issue/bug on Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants