podman icon indicating copy to clipboard operation
podman copied to clipboard

Podman machine user UID on WSL collides on another WSL user when systemd is enabled

Open rdbisme opened this issue 11 months ago • 3 comments

Issue Description

Basically what I've also reported here, on WSL repo. Not sure if it's a podman problem or a WSL problem.

When systemd is enabled, podman-machine default VM has the same UID as the "user WSL". The [email protected] than fails to start, and the podman-user.sock is not created, breaking podman-remote in rootless mode.

I tried changing the UID of the "work WSL" (i.e. not the podman-machine-default), but now I'm experiencing permission problems on the exported socket (because that one has UID 1000).

❯ ls -al /mnt/wsl/podman-sockets/podman-machine-default
total 0
drwxrwxrwx 2 root root 80 Dec 28 00:37 .
drwxrwxrwx 3 root root 60 Dec 28 00:37 ..
srw-rw---- 1 root   10  0 Dec 28 00:37 podman-root.sock
srw-rw---- 1 1000 1000  0 Dec 28 00:37 podman-user.sock
❯ id

I don't understand why two machines interfere with each other systemd processes tho.

Steps to reproduce the issue

Described in this other issue.

Describe the results you received

Based on which VMs is started first, the [email protected] is not started correctly for the second macine running.

Describe the results you expected

Describe the results you expected

podman info output

From my Arch WSL:

Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM
Error: unable to connect to Podman socket: Get "http://d/v5.7.1/libpod/_ping": dial unix /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock: connect: permission denied: unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock

From Windows:

Client:
  APIVersion: 5.7.1
  Built: 1765378491
  BuiltTime: Wed Dec 10 15:54:51 2025
  GitCommit: f845d14e941889ba4c071f35233d09b29d363c75
  GoVersion: go1.25.5
  Os: windows
  OsArch: windows/amd64
  Version: 5.7.1
host:
  arch: amd64
  buildahVersion: 1.39.4
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: cgroupfs
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.13-1.fc41.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.13, commit: '
  cpuUtilization:
    idlePercent: 99.94
    systemPercent: 0.05
    userPercent: 0.01
  cpus: 12
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: container
    version: "41"
  eventLogger: journald
  freeLocks: 2048
  hostname: CiD
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 6.6.87.2-microsoft-standard-WSL2
  linkmode: dynamic
  logDriver: journald
  memFree: 15894007808
  memTotal: 16728145920
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.14.0-1.fc41.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.14.0
    package: netavark-1.14.1-1.fc41.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.14.1
  ociRuntime:
    name: crun
    package: crun-1.21-1.fc41.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.21
      commit: 10269840aa07fb7e6b7e1acff6198692d8ff5c88
      rundir: /run/user/1000/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^20250415.g2340bbf-1.fc41.x86_64
    version: ""
  remoteSocket:
    exists: true
    path: unix:///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: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: true
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 4294967296
  swapTotal: 4294967296
  uptime: 1h 29m 33.00s (Approximately 0.04 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /home/user/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/user/.local/share/containers/storage
  graphRootAllocated: 1081101176832
  graphRootUsed: 1118728192
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 1
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/user/.local/share/containers/storage/volumes
version:
  APIVersion: 5.4.2
  BuildOrigin: Fedora Project
  Built: 1743552000
  BuiltTime: Wed Apr  2 02:00:00 2025
  GitCommit: be85287fcf4590961614ee37be65eeb315e5d9ff
  GoVersion: go1.23.7
  Os: linux
  OsArch: linux/amd64
  Version: 5.4.2

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

  • Podman installed using scoop in the Windows host.
  • Podman also installed using pacman in the "work" WSL, with CONTAINER_HOST=unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

rdbisme avatar Dec 27 '25 23:12 rdbisme

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

github-actions[bot] avatar Jan 27 '26 00:01 github-actions[bot]

We're having the same issue and can reproduce it very easily by installing Podman (WSL2 backend) and Ubuntu 26.04 distro. I can't understand how this isn't a wider issue as I can't not repro it.

EBrookeLoreto avatar Sep 04 '26 15:09 EBrookeLoreto

I had the same issue today. Version: Podman v6.2.0, installed via Podman Desktop installation. WSL 2 integration.

System: WSL2 communication between other distros installed podman for user/rootless podman access.

Rootful connection has/I had no problem with. Affected only user/rootless mode.

The issue was cause not properly unmounting creted stale/old socket.

The fix for this problem is to edit service for user: wsl -d <your podman machine name>

Then inside the machine

Edit file inside your machine /home/user/.config/systemd/user/podman-mnt-bindings.service:

[Service]
RemainAfterExit=true
Type=oneshot
# Consistency with system service (supports racing)
ExecStartPre=mkdir -p -m 777 /mnt/wsl/podman-sockets
ExecStartPre=mkdir -p -m 777 /mnt/wsl/podman-sockets/podman-machine-default
ExecStartPre=-sudo /usr/bin/umount /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock     # add this line to the service and save 
ExecStartPre=touch /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
# Relies on /etc/fstab entry for user mounting
ExecStart=mount /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
ExecStop=umount /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock

This will persist after restart, no futher hustle.

We hope that there will be a patch soon.

vizo-git avatar Nov 26 '26 06:11 vizo-git