Containerization has become a fundamental technology in modern software development and deployment. Containers, with their ability to package applications and their dependencies into isolated units, streamline development, enhance portability, and simplify the deployment process. Red Hat Podman is a containerization tool that is a nice Docker alternative with daemonless technology, which allows us to run and manage containers with a focus on security and simplicity. Although Podman is primarily associated with Linux, it is also available for Windows, enabling Windows users to harness the power of containers.
So, you can follow this tutorial performed completely using the command line to install the Podman, a Docker alternative on Windows 11 or 10 using PowerShell or CMD.
Why Use Red Hat Podman?
Before hoping for tutorial steps, let’s look at some key points that make Podman worth using for creating virtual containers. Here are some:
- Lightweight and Secure: Podman is known for its lightweight nature and strong focus on security. It operates without a daemon, reducing the attack surface and enhancing security.
- Linux Compatibility: Podman aims to be compatible with the Docker CLI, making it a suitable choice for those transitioning from Docker while enjoying the added security features.
- Open Source: Podman is an open-source project developed by Red Hat, making it freely available and actively maintained by a dedicated community.
Installing Red Hat Podman on Windows 11 or 10
Follow these steps to install Red Hat Podman on your Windows machine using the command prompt or Powershell:
Step 1: Check System Requirements
First, you must ensure that your Windows system is running with the latest updates so that it can meet the requirements to run the Podman. You should be on Windows 11 or Windows 10 version 1709 (build 16299) or later, and it must have Windows Subsystem for Linux 2 (WSL 2) and VM features enabled, well, if they are not activated yet then you can do it using the second step commands.
Step 2: Install WSL 2 and Virtual Machine platform
Let’s open Windows PowerShell or Command Prompt to start running the required commands.
For that right-click on the Windows 10 or 11 “Start” button and select PowerShell (Admin) or Terminal (Admin), whatever is available for you.
After that run the following command to enable the WSL feature, first:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Next, enable the Virtual Machine Platform feature:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your computer to apply the changes.
Step 3: Install Podman on Windows 10 or 11
After restarting your system again open the PowerShell as Admin and use the given Winget command to download and install RedHat Podman on Windows.
winget install RedHat.Podman
Step 4: Initialize the Podman Machine
Once the installation of Podman is completed, the next step is to initialize the Podman machine which will download the required backend for creating containers. In short, it will import a Linux operating system for setting up WSL, so that Podman can run containers natively like on any Linux machine.
podman machine init
Step 5: Start Podman Machine
As you are done with setting up Podman’s initial setup configuration on Windows, the next step is to start the initialized machine. For that, simply in your Windows command terminal type:
podman machine start
Step 6: Verify the Installation
To verify that Podman is installed correctly, you can run the following command on PowerShell or CMD.
You should see the version of Podman displayed in the output.
The command line of Podman works exactly like Docker, however, it is daemonless which makes it different from the Docker. We can use the Podman commands to manage containers, images, and pods, just as you would on a Linux system. You can also check our another tutorial to learn the Installation of Docker Desktop on Windows 11 or 10 via PowerShell, in case you are interested in it.
So to download some Container images, let’s say of Ubuntu, here is the command:
podman pull ubuntu
To check the downloaded image:
To quickly create a container, use the:
podman run -it ubuntu /bin/bash
Command Podman commands
Here are some common Podman commands with explanations that work similarly to Docker’s:
1. Pull an Image:
Use Podman pull to download a container image from a registry (e.g., Docker Hub).
podman pull ubuntu:latest
2. List Running Containers:
Display a list of currently running containers.
3. List All Containers:
Show a list of all containers, including stopped ones.
podman ps -a
4. Run a Container:
Create and start a container from an image. The -it flags allocate a terminal and make the container interactive.
podman run -it --rm ubuntu:latest /bin/bash
5. Stop a Container:
Stop a running container by specifying its container ID or name.
podman stop container_name_or_id
6. Remove a Container:
Remove a stopped container by specifying its container ID or name.
podman rm container_name_or_id
7. List Images:
Display a list of locally available container images.
8. Remove an Image:
Delete a container image from your local repository.
podman rmi image_name
9. Container Logs:
View the logs of a running or stopped container.
podman logs container_name_or_id
10. Execute a Command in a Running Container:
Run a command inside a running container without starting a new shell.
podman exec -it container_name_or_id /bin/bash
11. Port Mapping:
Map a container’s port to a host port. For example, this maps port 80 in the container to port 8080 on the host.
podman run -d -p 8080:80 nginx:latest
12. List Pods:
Display a list of pods (Podman’s concept for managing groups of containers).
podman pod list
13. Create a New Pod:
Create a new pod and add containers to it.
podman pod create --name mypod
14. Add a Container to a Pod:
Add an existing container to a pod.
podman pod container add mypod container_name_or_id
15. Remove a Container from a Pod:
podman pod container remove mypod container_name_or_id
16. Delete a Pod:
Delete a pod and all its containers.
podman pod rm mypod
Those who also want to use the Powershell or Command prompt to remove Podman on Windows can use the given command:
Run Command terminal as admin and then use:
winget uninstall RedHat. Podman