Podman on Ubuntu on Windows Subsystem for Linux (WSL) 2
January 14, 2022
This article shows how to install Podman on Ubuntu on Windows Subsystem for Linux (WSL) 2.
1. Prerequisites
Ubuntu 20.04 distro of Windows Subsystem for Linux (WSL) 2 must be installed. If you are unable to download it from Microsoft Store, download it manually.
2. Install Podman
. /etc/os-release
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/x${NAME}_${VERSION_ID}/Release.key -O Release.key
sudo apt-key add - < Release.key
sudo apt-get update -qq
sudo apt-get -qq -y install podman
$ podman --version
podman version 3.4.2
3. Use file logging and cgroupfs
If not existing already, copy /usr/share/containers/containers.conf
to /etc/containers
and/or ~/.config/containers
.
mkdir -p ~/.config/containers
cp /usr/share/containers/containers.conf ~/.config/containers/containers.conf
Once the file exists, edit it as follows:
cgroup_manager
= "cgroupfs"
(not "systemd"
)
events_logger
= "file"
(not "journald"
)
4. Test Podman
$ podman pull docker.io/library/httpd
$ podman run -dt -p 8080:80/tcp docker.io/library/httpd
$ podman ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b8d423c43663 docker.io/library/httpd:latest httpd-foreground 6 seconds ago Up 6 seconds ago 0.0.0.0:8080->80/tcp trusting_raman
$ curl http://localhost:8080
<html><body><h1>It works!</h1></body></html>
Cleanup.
podman stop -l
podman rm -l
podman rmi docker.io/library/httpd