๐ Complete Tutorial: Accessing Podman Desktop Containers from Ubuntu WSL
Ever wished you could seamlessly manage your Podman containers from your Ubuntu WSL terminal while still enjoying the slick UI of Podman Desktop on Windows? ๐ค You're in luck! This tutorial will guide you through setting up this powerful integration, giving you the best of both worlds. ๐ปโจ
This is super useful for developers who want to leverage the Linux environment of WSL for their container workflows, while keeping Podman Desktop as their central hub for visual management. Let's dive in! ๐ณ
๐ Prerequisites
Before we get started, make sure you have these essentials in place:
- Podman Desktop installed and happily running on your Windows machine.
- An Ubuntu WSL distribution already installed and configured.
- A Podman Machine created in Podman Desktop. (This usually happens automatically during the initial setup. ๐)
๐ก Overview
Podman Desktop is smart! It sets up a special WSL virtual machine called "Podman Machine" and configures the Windows Podman client to chat with it. However, it doesn't automatically extend this courtesy to your other WSL distributions (like our beloved Ubuntu). Our mission: to bridge this communication gap! ๐
Step 1: Access Your Ubuntu WSL Distribution ๐ช
First things first, let's jump into your Ubuntu WSL session. Open your favorite Windows terminal (Command Prompt, PowerShell, or Windows Terminal) and type:
wsl --distribution Ubuntu
If Ubuntu is your go-to default distribution, a simple wsl
will do the trick! ๐
Step 2: Install Podman Remote Client ๐ฅ
Instead of a full-blown Podman installation from Ubuntu's repositories, we're going for the leaner, meaner podman-remote
binary. This ensures you're always on the cutting edge with the latest features and best compatibility! โ๏ธ
Download the Latest Podman Remote Binary
Always check the Podman releases page for the absolute latest version.
Then, download and install the binary (remember to replace v5.5.1
with the actual latest version you found!):
wget https://github.com/containers/podman/releases/download/v5.5.1/podman-remote-static-linux_amd64.tar.gz
Configure the Binary ๐ ๏ธ
Let's make sure your system knows where to find podman-remote
and give it a friendly alias. Edit your .zshrc
(or .bashrc
if you're using Bash):
echo 'export PATH="$PATH:/usr/local/bin"' >> ~/.zshrc
echo 'alias podman="podman-remote-static-linux_amd64"' >> ~/.zshrc
source ~/.zshrc
Step 3: Identify Your Podman Machine Configuration ๐ต๏ธโโ๏ธ
Before we connect, we need to know which socket your Podman Desktop is currently using.
Find Available Sockets ๐
List the available Podman sockets in your WSL distribution:
find /mnt/wsl/podman-sockets/ -name '*.sock'
You should see something like this:
/mnt/wsl/podman-sockets/podman-machine-default/podman-root.sock
/mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
Identify the Active Socket ๐
Now, open a new Command Prompt or PowerShell window on Windows (don't close your WSL terminal yet!). Check which connection Podman Desktop is using:
podman system connection list
Look for the connection marked true
in the Default
column. The URI
will tell you if it's rootful
or rootless
:
-
Rootful:
ssh://root@127.0.0.1:PORT/run/podman/podman.sock
(most common, default) -
Rootless:
ssh://user@127.0.0.1:PORT/run/user/1000/podman/podman.sock
### Step 4: Configure the Podman Connection ๐ค
Based on whether your Podman Desktop is using rootful or rootless mode, let's set up the connection!
For Rootful Podman (Default) ๐
If your Podman Desktop is in rootful mode (which is typically the default):
podman system connection add --default podman-machine-default-root unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-root.sock
For Rootless Podman ๐ฑ
If your Podman Desktop is using rootless mode:
podman system connection add --default podman-machine-default-user unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
Step 5: Configure User Permissions ๐
Your WSL user needs the right permissions to talk to the Podman Machine socket. Add your user to the appropriate group and then exit your WSL session to apply the changes. This step is crucial! ๐
sudo usermod --append --groups 10 $(whoami)
exit
Step 6: Test the Connection! โ
It's showtime! Restart your WSL session and let's verify everything is working smoothly.
wsl
Verify Group Membership ๐ฅ
Double-check that your user is now in the correct group:
groups
You should see uucp
in the list (this corresponds to group ID 10
for rootful access).
Verify Podman Connection ๐
Confirm that the connection is properly configured:
podman system connection list
Test Podman Version ๐งช
Now, the moment of truth! Verify that Podman in your WSL can communicate with the remote machine:
podman version
You should see both Client
and Server
versions, indicating a glorious, successful connection! ๐
Test Container Operations ๐ฆ
Let's run a quick test by launching a simple container:
podman run quay.io/podman/hello
podman ps -a --last 1
Voilร ! The container should magically appear in both your WSL terminal output and in Podman Desktop's container list. Synchronization at its finest! ๐ฏโโ๏ธ
Step 7: Switching Between Rootful and Rootless (Optional) ๐
Sometimes you might need to flip between rootful and rootless modes. Here's how:
To Switch to Rootless Mode:
-
In Windows terminal:
podman machine set --rootful=false
-
In WSL:
podman system connection add --default podman-machine-default-user unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-user.sock
To Switch to Rootful Mode:
-
In Windows terminal:
podman machine set --rootful=true
-
In WSL:
podman system connection add --default podman-machine-default-root unix:///mnt/wsl/podman-sockets/podman-machine-default/podman-root.sock
๐ Troubleshooting Corner
Ran into a snag? Don't worry, we've got you covered with some common fixes!
Permission Denied Errors ๐ซ
If you're seeing Permission denied
errors:
-
Ensure you're in the correct group:
groups | grep uucp
-
If not, add yourself to the group again and exit/restart:
sudo usermod --append --groups 10 $(whoami) exit
-
Restart WSL completely:
wsl --shutdown
Socket Not Found ๐
If the socket files seem to be playing hide-and-seek:
- Ensure Podman Desktop is running. ๐โโ๏ธ
- Ensure the Podman Machine is started in Podman Desktop.
-
Check if the machine name is different (it might not be
podman-machine-default
):
ls /mnt/wsl/podman-sockets/
Connection Refused ๐
If you're getting Connection refused
errors:
- Verify Podman Desktop is running.
- Check that the Podman Machine is started.
- Try restarting the Podman Machine from Podman Desktop. ๐
โ๏ธ Custom Configurations
A couple of notes for more unique setups:
Custom WSL Distribution ๐ง
If you're using a WSL distribution other than Ubuntu, the group names for group ID 10
might be different. You can find the correct group name using:
getent group 10
Custom Podman Machine Name ๐ท๏ธ
If you've been adventurous and created a custom Podman Machine with a different name, simply replace podman-machine-default
in the socket paths with your machine's actual name.
โก๏ธ Next Steps
Congratulations! ๐ You've successfully configured your Ubuntu WSL distribution to communicate with Podman Desktop's container engine. Now, the world of containerized development is your oyster within WSL!
You can now:
- Use all Podman commands directly from your WSL terminal.
- Manage containers that appear seamlessly in both your WSL and Podman Desktop.
- Start experimenting with container orchestration tools like Podman Compose.
- Deeply integrate container workflows into your WSL development environment.
๐ Summary
You've done it! You've successfully linked your Ubuntu WSL with Podman Desktop, allowing you to enjoy the power of the Podman CLI from within WSL while benefiting from Podman Desktop's excellent graphical interface.
Key takeaways to remember:
- Always use
podman-remote
for the latest features and best compatibility. - Configure the correct socket path based on your Podman Desktop's rootful/rootless setting.
- Proper group permissions are essential for socket access.
- The magic part: Both WSL and Podman Desktop will now show the same containers and images! โจ
Happy containerizing! ๐
Great tutorial! Really helpful to get started with podman.
You just forgot to explain how to install the software after you download it with
I just figured out you simply have to
untar
it and move it to/usr/local/bin
, but that would be a nice addition to make this tutorial complete.