You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

As you may already know Windows Subsystem for Linux (WSL) lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a virtual machine.

WSL 2 is a new version of the Windows Subsystem for Linux architecture that powers the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. Its primary goals are to increase file system performance, as well as adding full system call compatibility.

Before we hit the road running and get Podman running on Windows 10, we have to install WSL2, get our favorite Linux distribution, and proceed to install Podman therein. So the guide will be divided into two sections. The first section handling the installation of WSL2 and the next section handling the installation of podman together with testing. Commençons

Section 1: Install Windows Subsystem for Linux

Follow the steps below to install WSL2 and to get a favorite Linux distribution up and running. I will be using Ubuntu 20.04.

Step 1: Enable Windows Subsystem for Linux

Before installing any Linux distributions on Windows, you must enable the “Windows Subsystem for Linux” optional feature.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

That will have WSL 1 ready in Windows. To have WSL 2, we have to update it as shown in the next step.

Step 2: Update to WSL 2

To update to WSL 2, Windows must meet the follow criteria:

  • Running Windows 10, updated to version 2004, Build 19041 or higher.
    Check your Windows version by selecting the Windows logo key + R, type winver, select OK.
  • Enable the ‘Virtual Machine Platform’ optional component
    Before installing WSL 2, you must enable the “Virtual Machine Platform” optional feature.

Please note that nothing will work later if the requirements above are not met. Update your Windows 10 to 2004, Build 19041 or higher.

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your machine to complete the WSL install and update to WSL 2.

Step 3: Install Linux Distro

After your computer is back after the reboot, open up “Microsoft Store” application and search for your favorite Linux Distro. I am going to search and install Ubuntu 20.04

Search for Ubuntu

Install Ubuntu 20.04 LTS

Be patient as it downloads.

You can as well launch if after it has installed to confirm that it is healthy.

And there we go!

You will be asked to enter a username and password. Kindly do!

After that, everything should be brilliantly okay as shown below. We are logged in and ready for the next Step.

Step 4: Set WSL 2 as your default version (Optional)

On setting WSL 2 version, you have two options.

Option 1: You can set the specific Linux distribution to be backed by either version of WSL by running the following command on the PowerShell

wsl --set-version  <distribution name> <versionNumber>

Make sure to replace it with the actual name of your distribution and with the number ‘1’ or ‘2’. You can change back to WSL 1 at any time by running the same command as above but replacing the ‘2’ with a ‘1’.

You can check all of your distributions by keying in the command below:

wsl --list --all

Option 2: You can set WSL 2 as the default global architecture by running the command below on PowerShell.

wsl --set-default-version 2

I am going to go with option one but you are free to choose either.

wsl --set-version  Ubuntu-20.04 2

If you get a message like:
WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel

Click this link to download the Linux kernel update package then install it.
You can find out more about this on the URL provided next. https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel

After the package is installed, issue the command again. It will take some few seconds to complete.

wsl --set-version  Ubuntu-20.04 2

After it is done converting, you can check the version of WSL that your Linux Distros have by running the command below

wsl -l -v

  NAME            STATE           VERSION
* Ubuntu-18.04    Stopped         1
  Ubuntu-20.04    Stopped         2

As you can see, our Ubuntu 20.04 is in WSL version 2 while the other one is in WSL version 1. You can convert from one WSL version to the other as you wish.

Section 2: Installing Podman

Once section 1 has been accomplished, launch the distro you would wish to install podman on (Mine is Ubuntu-20.04) and then proceed to the step below.

Step 1: Add the Podman PPA and install Podman

The easiest way to begin the installation of Podman on Ubuntu is to use the Kubic project. The Kubic project provides packages for Ubuntu 18.04, 19.04, 19.10 and 20.04. You can easily add this package to your Ubuntu distribution as follows

. /etc/os-release
sudo sh -c "echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /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 -
sudo apt-get update -qq
sudo apt-get -qq -y install podman
sudo mkdir -p /etc/containers
echo -e "[registries.search]\nregistries = ['docker.io', 'quay.io']" | sudo tee /etc/containers/registries.conf

Confirm if our podman was installed successfully

podman info

host:
  arch: amd64
  buildahVersion: 1.14.9
  cgroupVersion: v1
  conmon:
    package: 'conmon: /usr/libexec/podman/conmon'
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.0.16, commit: '
  cpus: 8
  distribution:
    distribution: ubuntu
    version: "20.04"
  eventLogger: file
  hostname: Kibet-pc
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 4.19.104-microsoft-standard
  memFree: 12580970496
  memTotal: 13297381376
  ociRuntime:
    name: runc
    package: 'runc: /usr/sbin/runc'
    path: /usr/sbin/runc
    version: 'runc version spec: 1.0.1-dev'
  os: linux
  rootless: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: 'slirp4netns: /usr/bin/slirp4netns'
    version: |-
      slirp4netns version 1.0.0
      commit: unknown
      libslirp: 4.2.0
  swapFree: 4294967296
  swapTotal: 4294967296
  uptime: 1h 36m 59.79s (Approximately 0.04 days)
registries:
  search:
  - docker.io
  - quay.io
store:
  configFile: /home/tech/.config/containers/storage.conf
  containerStore:
    number: 11
    paused: 0
    running: 1
    stopped: 10
  graphDriverName: vfs
  graphOptions: {}
  graphRoot: /home/tech/.local/share/containers/storage
  graphStatus: {}
  imageStore:
    number: 2
  runRoot: /tmp/run-1000/containers
  volumePath: /home/tech/.local/share/containers/storage/volumes

You should note that Podman has been changed to no longer generate configuration files in the user’s home directory automatically. Find out more about this on this case risen on GitHub.

Step 2: Pull and run a sample container

Run the following command to pull apline from docker.io

podman pull alpine

Trying to pull docker.io/library/alpine...
Getting image source signatures
Copying blob df20fa9351a1 done
Copying config a24bb40132 done
Writing manifest to image destination
Storing signatures
a24bb4013296f61e89ba57005a7b3e52274d8edd3ae2077d04395f806b63d83e

Once pulled, you can view all of your images like this:

podman images

REPOSITORY                 TAG      IMAGE ID       CREATED       SIZE
docker.io/library/nginx    latest   2622e6cca7eb   8 days ago    136 MB
docker.io/library/alpine   latest   a24bb4013296   2 weeks ago   5.85 MB

Let us now run our alpine image and see if it responds with grace.

podman run -it --rm alpine /bin/sh

/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
v3.12.0-74-gb8f92cf12a [http://dl-cdn.alpinelinux.org/alpine/v3.12/main]
v3.12.0-76-ge6ea27f814 [http://dl-cdn.alpinelinux.org/alpine/v3.12/community]
OK: 12734 distinct packages available
/ #

That was remarkably beautiful. You can open another terminal/instance and check if our container is running.

podman ps

CONTAINER ID  IMAGE                            COMMAND  CREATED        STATUS            PORTS  NAMES
d47342edeb3c  docker.io/library/alpine:latest  /bin/sh  2 minutes ago  Up 2 minutes ago         festive_shtern

And our container is swimming nice and happy! Good stuff.

To conclude

We hope the sail in this yacht has been awesome thus far and believe that you enjoyed it as much as we did. As a result, we are now able to run podman in a Linux distro under WSL version 2. Thank you for giving us company during the sail and as we dock, you can enjoy another journey by clicking on the links below.

Setup Docker Container Registry with Podman & Let’s Encrypt SSL

How To Install Podman on Arch Linux | Manjaro

How To Install Podman on Debian

Install and Use Podman on CentOS 8 | RHEL 8

How To Install Podman on Ubuntu

How To run Docker Containers using Podman and Libpod

How To Build OCI & Docker Container Images With Buildah

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF