DEV Community

Cover image for Using podman instead of docker on Windows Subsystem for Linux (WSL 2)

Using podman instead of docker on Windows Subsystem for Linux (WSL 2)

Jonathan Bowman
Constantly learning to develop software. A Python enthusiast. Works at Candoris, helping clients use Salesforce effectively. Want to buy me coffee?
Updated on ・3 min read

With Windows Subsystem for Linux (WSL) version 2, running Linux containers is possible and easy. However, Docker does not work without the docker daemon running, systemd is usually used to govern this, and WSL typically does not have systemd running.

Enter podman.

Podman is a drop-in replacement for the docker commandline tool. It is "daemonless" (in other words, does not require systemd or other service to run in the background), and is backed by Redhat. Podman also works well without root—in other words, containers can easily run in userspace.

Note that it is possible to run the docker daemon without systemd and on pretty much any WSL distribution, even without Docker Desktop. I documented my working setup in a separate article. But I still favor podman for reasons noted in this article.

I use Fedora (you may read more about how I installed Fedora on WSL). In my setup, I needed some minor configuration in order for podman to work properly, and to run rootless. Here are the steps I used.

Installing podman

To install podman, follow the official instructions. Most likely, guidance for your distro should be included there.

A quick summary:

  • Fedora: sudo dnf install podman
  • Centos: sudo yum --enablerepo=extras install podman
  • Debian 11 (bullseye) or later, or sid/unstable: sudo apt install podman
  • ArchLinux: sudo pacman -S podman and then tweaks for rootless
  • Debian 10: see the guide for how to set up apt to use the Kubic repos then make sure to run sudo apt update then sudo apt install podman


Without systemd, the $XDG_RUNTIME_DIR was not available for podman to use for temporary files. I added the following to my ~/.bashrc file:

if [[ -z "$XDG_RUNTIME_DIR" ]]; then
  export XDG_RUNTIME_DIR=/run/user/$UID
  if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
    export XDG_RUNTIME_DIR=/tmp/$USER-runtime
    if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
      mkdir -m 0700 "$XDG_RUNTIME_DIR"
Enter fullscreen mode Exit fullscreen mode

This script checks if the $XDG_RUNTIME_DIR is set, and, if not, sets it to the default systemd location (/run/user/$UID). If that does not exist, then set and create a temporary directory for the current user.

(Now source your .bashrc with source ~/.bashrc to update environment variables.)

Use file logging and cgroupfs

Do you have /etc/containers/containers.conf or ~/.config/containers/containers.conf? If so, great. On Fedora, and possibly other distributions, you may first need to copy /usr/share/containers/containers.conf to /etc/containers and/or ~/.config/containers. Once the file exists, edit it, making sure that:

  • cgroup_manager = "cgroupfs" (not systemd)
  • events_logger = "file" (not journald)

Issue with shadow-utils on Fedora

On Fedora, I had to reinstall shadow-utils in order to have a properly installed newgidmap and newuidmap:

sudo dnf reinstall shadow-utils
Enter fullscreen mode Exit fullscreen mode

Test and prosper

The following should give you a simple command prompt:

$ podman run -it
Trying to pull
Getting image source signatures
Copying blob df20fa9351a1 done
Copying config a24bb40132 done
Writing manifest to image destination
Storing signatures
/ #
Enter fullscreen mode Exit fullscreen mode



Discussion (12)

agritheory profile image
Tyler Matteson • Edited

Thanks for this! I just installed Podman on WSL/Ubuntu 18.04 and wanted to leave the instructions for the next poor soul

echo 'deb /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
curl -L | sudo apt-key add -

sudo apt-get update
sudo apt-get -y install podman
Enter fullscreen mode Exit fullscreen mode
thetechoddbug profile image
thetechoddbug (José María Gutiérrez)

This is not working for me in WSL1. Are these instructions for WSL2?

Thanks in advance.

agritheory profile image
Tyler Matteson

Yes, these are for WSL2.

bhayes profile image

Really wanted to try podman but I cant.
podman run hello-world works fine, however cant use it as a "drop in replacement for docker" as all our projects use docker-compose.
Apparently there is support fo docker compose in podman v3 but it relies on systemd init and cant be run on wsl. 😢

Any ideas?

gbraad profile image
Gerard Braad

Automated steps for the config changes:

$ sudo -i
$ cp /usr/share/containers/containers.conf /etc/containers/containers.conf && \
 sed -i '/^# cgroup_manager = "systemd"/ a cgroup_manager = "cgroupfs"' /etc/containers/containers.conf && \
 sed -i '/^# events_logger = "journald"/ a events_logger = "file"' /etc/containers/containers.conf
$ dnf reinstall -y shadow-utils
Enter fullscreen mode Exit fullscreen mode
samuelhart profile image
Samuel Hart

Thanks for posting this. I used the WSL Fedora Remix .appxbundle from WhiteWaterFoundary (free on Github) and got podman to work. It was almost working out of the box, but I needed the modificatiosn to containers.conf to get it working without errors.

For what it's worth, I had the exact same issues using your instructions for creating fedora from the latest fedora container images but I hadn't found this article for podman at the time. I may shift back to that because I'm not sure exactly what else the Fedora Remix does/doesn't include. Although it makes a nice windows menu application for the distro (like you'll get with Ubuntu from the Microsoft Store).

bowmanjd profile image
Jonathan Bowman Author

Good to hear! Perhaps I should link to this article from that one. Podman does work great without systemd, but needs a bit of customization to do so, as you have discovered as well.

trallnag profile image
Tim Schwenke

The config modification worked well for me on WSL2 Ubuntu 20.10. I installed Podman and so on directly through apt

bowmanjd profile image
Jonathan Bowman Author

Glad to hear it!

krumware profile image
Colin Griffin

Thanks for this! Is there a way to get this rolling to create the /var/run/podman/podman.sock? docker-compose appears to not like the lack of socket on WSL, since it relies on $DOCKER_HOST

bowmanjd profile image
Jonathan Bowman Author

I am sure that would be possible. It would be similar to getting a doctor socket working in WSL.

Curious though. If you are open to a socket, would you be open to simply using docker?

krumware profile image
Colin Griffin

I was hoping to go podman-first, or using docker with the shared socket per one of the other posts. One problem is that I could not get windows and wsl to play beautifully with docker desktop on windows but podman on wsl. I'm trying to orchestrate the transition from docker-compose to podman or kompose, and there are small environmental gaps that are blocking. But we're almost there!