Accessing Podman from another WSL distribution
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
Start Ubuntu in WSL
wsl -d Ubuntu
Install
podman-remote
, optionally installpodman-compose
sudo apt-get update sudo apt-get install -y podman-remote podman-compose
Add
podman-machine-default
as remote connectionpodman 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
Test connection
podman-remote version
Note: If successful, the output should have a
client
section and aserver
sectionOptional, create
alias
forpodman
anddocker
in~/.bash_aliases
alias podman=podman-remote alias docker=podman-remote
SSH Connection
Start Ubuntu in WSL
wsl -d Ubuntu
Install
podman-remote
, optionally installpodman-compose
sudo apt-get update sudo apt-get install -y podman-remote podman-compose
Generate a local
ed25519
keyssh-keygen -t ed25519 -f ~/.ssh/podman
Copy the public key to Podman machine
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
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
inpodman-machine-default
.
In WSL distro (i.e. Ubuntu), add
podman-machine-default
as remote connectionpodman system connection add --default podman-machine-default-user --identity ~/.ssh/podman ssh://user@127.0.0.1:51405/run/user/1000/podman/podman.sock
Test connection
podman-remote version
Note: If successful, the output should have a
client
section and aserver
sectionOptional, create
alias
forpodman
anddocker
in~/.bash_aliases
alias podman=podman-remote alias docker=podman-remote