Skip to main content

How to run Podman on Windows

With a little help from Windows Subsystem for Linux, you can use Podman to build container images, run a web server in a container, and more.
Differences between containers and images

Photo by Karolina Grabowska from Pexels

In a recent Podman Community Cabal meeting, there was a discussion about running Podman on Windows. Many of the maintainers are Linux-focused and don't have a large amount of Windows development experience, so we were looking for ideas or volunteers to port Podman onto Windows. Cabal attendee Pavel Sosin mentioned he was running Podman on his Windows machine. That was news to many of us.

Pavel discovered a Fedora Remix version that runs on Windows in the Microsoft Store. He bought and installed it as an experiment and then tried running Podman in it. He was pleasantly surprised to find a recent version of Podman in the Fedora distribution. After hearing Pavel's story, I decided to try it on my home laptop running Windows 10. Here's how it went.

Prepare to install Linux on Windows

Before installing Linux, you must do a small bit of setup. Linux distributions that run on Windows rely on the Windows Subsystem for Linux (WSL2) to run. Depending on how old your Windows box is, you may not have it on board, or you may have WSL1 instead of WSL2. Microsoft has a very detailed web page with the steps required to install WSL2. For most people, it boils down to a couple of quick steps.

First, run Command Prompt or Windows PowerShell as an administrator. If you have an icon for either in your Start menu or taskbar, you can right-click on it and select Run as administrator. If you do not have either handy, press Windows key+X. Then select the one that's there, running it as an administrator.

Launching the command prompt in Windows
(Tom Sweeney, CC BY-SA 4.0)

Once you're in Command Prompt, install WSL 2. If it's already installed or needs an upgrade, the wsl.exe --install command will handle it. If things don't work, check the WSL2 installation page linked above.

Installing WSL2
(Tom Sweeney, CC BY-SA 4.0)

Once the installation is finished, you must reboot.

Rebooting after installing WSL2
(Tom Sweeney, CC BY-SA 4.0)

Enable cut and paste

Cut, copy, and paste are not turned on by default in the Command Prompt window. Right-click on the bar at the top of the window (it's the white bar in the image below), and then select the box next to Use Ctrl+Shift+C/V as Copy/Paste.

Enabling copy-paste in Command Prompt
(Tom Sweeney, CC BY-SA 4.0)

Install Fedora on Windows

After installing WSL2 and rebooting, Windows may spring up a Ubuntu instance and ask you for a username and password. If you want, you could continue on this path and run Podman in Ubuntu. That way, you wouldn't have to pay for Fedora Remix. However, if you don't mind paying the $10 or prefer this version of Fedora, you can start installing it. A quick aside, Fedora Remix is not an official version of Fedora, as far as I am aware, but it looks to be running the latest version available, and I could find no differences.

To install Fedora, click on the Windows icon in your taskbar and find the Microsoft Store in the list of options. After the Microsoft Store pops up, enter "Fedora" in the search box.

Fedora Remix in Windows Store
(Tom Sweeney, CC BY-SA 4.0)

Now for the tough part of this process: paying $9.99 (or, in my case, $10.61 after taxes) for Fedora, which is generally free. But I rationalized it; Whitewater Foundry had to do some work to make it live on Windows, and my expense voucher made it a tad less painless.

So with some trepidation, I hit the Buy button and put in my credit card information.

Buying Fedora Remix
(Tom Sweeney, CC BY-SA 4.0)

And after paying for Fedora, I downloaded and installed it from the Microsoft Store.

Downloading and installing Fedora Remix
(Tom Sweeney, CC BY-SA 4.0)

After the installation completes, click the Launch button to start Fedora.

Launching Fedora in Windows
(Tom Sweeney, CC BY-SA 4.0)

Now that you have Fedora up and running, set up a user account when prompted, and after sudoing, install Podman with dnf -y install podman.

Installing Podman
(Tom Sweeney, CC BY-SA 4.0)

Run a simple container

After the installation completes, do sudo -s while logged in, and then create a small Containerfile. Here is my Containerfile:

RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay

And then run the command podman build -t whale . followed by podman run whale.

Building Whalesay
(Tom Sweeney, CC BY-SA 4.0)

Create a more useful container

The whalesay container was the first one I ran, and it's always tickled me. However, it's not useful in the real world, other than as a quick test, so I thought I'd try setting up an Nginx container running a web server. I've found Peter McKee's article to be especially useful when running Nginx. So I followed his examples to set up a web server with its own home page, just by changing docker to podman in the examples.

[ Get this free book from Red Hat and O'Reilly - Kubernetes operators: automating the container orchestration platform. ]

First, I created a directory called Podman\site-content at the top of my C:\ directory in my Windows machine:

Creating podman/site-content directory
(Tom Sweeney, CC BY-SA 4.0)

Then I created a text file named C:\Podman\site-content\index.html with:

<!doctype html>
<html lang="en">
  <meta charset="utf-8">
  <title>Podman Nginx on Windows!</title>
  <h2>Hello from Nginx container on Windows</h2>
Creating index file in podman/site-content directory
(Tom Sweeney, CC BY-SA 4.0)

And then I ran:

podman run -it --rm -d -p 8080:80 --name web -v /mnt/c/Podman/site-content:/usr/share/nginx/html nginx

Because I had previously pulled the container image, I didn't get a pop up asking which image to select.

Starting the container
(Tom Sweeney, CC BY-SA 4.0)

After that was up and running, I opened Microsoft Edge on my Windows machine and pinged the web server.

Running Nginx container
(Tom Sweeney, CC BY-SA 4.0)

Run Fedora

During the installation process, Windows adds an icon for Fedora Remix for WSL to the Start menu. Just click on it to start a new Fedora instance whenever you want.

Fedora in Windows Start menu
(Tom Sweeney, CC BY-SA 4.0)

Wrapping up

Viola! Podman is running on Fedora, which is running on Windows. I've not played with this much yet, and I've heard there may be limitations with network connections to the containers from the host Windows machine. But volume-mounting a native Windows directory works surprisingly well.

All in all, this version of Fedora looks to be a viable option for building container images, running a web server in a container, and more! I was pleasantly surprised how well it worked, and if you want to avoid paying the $10 for Fedora, you could do the same thing with the free Ubuntu and possibly other distributions, too.

Check out these related articles on Enable Sysadmin

Topics:   Containers   Linux   Podman   Windows  
Author’s photo

Tom Sweeney

Software engineer at Red Hat working on containers focusing on the Buildah and Podman projects. Manages the and websites and can be found on freenode at #buildah and #podman. More about me

On Demand: Red Hat Summit 2021 Virtual Experience

Relive our April event with demos, keynotes, and technical sessions from
experts, all available on demand.

Related Content