Life's random bits By b1thunt3r (aka Ishan Jain)…
Accessing Podman from another WSL distribution

Accessing Podman from another WSL distribution

Ishan jain
You might have other WSL distributions running and want to access from there to your Podman Desktop containers.

In previous post I talked about how to install and run Podman WSL.

Even though I am going to discuses accessing Podman Machine from another WSL distributions (i.e. Ubuntu), you can use SSH connection to access Podman Machine from any machine that can access SSH running in Podman Machine.

Note: You can only mount volumes available in podman-machine. You can access Windows file system using Unixy (i.e. /mnt/c/Users/User/myfolder) style paths.

Unix Socket

  1. Start Ubuntu in WSL

    wsl -d Ubuntu
    
  2. Install podman-remote, optionally install podman-compose

    sudo apt-get update
    sudo apt-get install -y podman-remote podman-compose
    
  3. Add podman-machine-default as remote connection

    podman system connection add --default podman-machine-default-user unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
    

    Troubleshoot: Make sure $USER is part of group that owns /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock

    ls -Al /mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
    sudo usermod --append --groups <group> $USER
    
  4. Test connection

    podman-remote version
    

    Note: If successful, the output should have a client section and a server section

  5. Optional, create alias for podman and docker in ~/.bash_aliases

    alias podman=podman-remote
    alias docker=podman-remote
    

SSH Connection

  1. Start Ubuntu in WSL

    wsl -d Ubuntu
    
  2. Install podman-remote, optionally install podman-compose

    sudo apt-get update
    sudo apt-get install -y podman-remote podman-compose
    
  3. Generate a local ed25519 key

    ssh-keygen -t ed25519 -f ~/.ssh/podman
    
  4. Copy the public key to Podman machine

    1. Connect to Podman machine (From Windows Terminal, not WSL)

      podman machine ssh podman-machine-default
      

      Note: You can list all the Podman machines with podman machine ls

    2. Copy public key to ~/.ssh/authorized_keys

      Tip: You need to add the content of ~/.ssh/podman (from WSL distro, i.e. Ubuntu) to ~/.ssh/authorized_keys in podman-machine-default.

  5. In WSL distro (i.e. Ubuntu), add podman-machine-default as remote connection

    podman system connection add --default podman-machine-default-user --identity ~/.ssh/podman ssh://user@127.0.0.1:51405/run/user/1000/podman/podman.sock
    
  6. Test connection

    podman-remote version
    

    Note: If successful, the output should have a client section and a server section

  7. Optional, create alias for podman and docker in ~/.bash_aliases

    alias podman=podman-remote
    alias docker=podman-remote
    

Resouces