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.
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.
Once the installation is finished, you must reboot.
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.
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.
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.
And after paying for Fedora, I downloaded and installed it from the Microsoft Store.
After the installation completes, click the Launch button to start Fedora.
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.
Run a simple container
After the installation completes, do
sudo -s while logged in, and then create a small Containerfile. Here is my Containerfile:
FROM docker.io/docker/whalesay:latest 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.
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
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:
Then I created a text file named
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Podman Nginx on Windows!</title> </head> <body> <h2>Hello from Nginx container on Windows</h2> </body> </html>
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
docker.io/library/nginx:latest container image, I didn't get a pop up asking which image to select.
After that was up and running, I opened Microsoft Edge on my Windows machine and pinged the web server.
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.
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.