Configuring Podman for WSL2

This post is intended to serve as a sort of update to Red Hat's (now outdated since v3 of Podman) blog post on how to run Podman in WSL2.

The commands for the below presume that you are running Ubuntu 20.04 or higher, but the WSL2 specific configuration at the end is independent of which Linux distro you are using.

You can find the specific installation dependencies and commands for your distro in the Podman docs.

Basic Install

Here are the commands I used in order to install Podman on Ubuntu.

First, you must determine the version of Ubuntu you're running, if you don't already know. Then you export that to an environment variable, which I named VERSION_ID in order to be able to use that when adding repos from the Kubic project, which was necessary for my specific OS version.

cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -
export VERSION_ID="20.04"
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install podman

WSL2 Specifics

OK - now comes the WSL2 specific stuff that you need to change in order for Podman to work. Basically, you just have to change the systemd-specific stuff (default) to non-systemd stuff.

With version 3+ of Podman, this can all be done in one file.

First, make the requisite directory. Mine was not automatically created, but YMMV. Then, create a containers.conf file in that directory.

mkdir ~/.config/containers
vim ~/.config/containers/containers.conf

Inside that file, simply add the following:

[engine]
events_logger="file"
cgroup_manager="cgroupfs"

The default events_logger is journald and the default cgroup_manager is systemd, in case you were curious.

Now Podman should run for you with no issues, and you don't need to run that clunky Docker daemon in Windows anymore 🎉