Follow the steps below to install Red Hat Podman on a Windows machine using Command Prompt or Powershell:
First, you must ensure that your Windows system is running with the latest updates so that it meets the requirements for running Podman. You should be using Windows 11 or Windows 10 version 1709 (Build 16299) or later, and the Windows Subsystem for Linux 2 (WSL 2) and VM features must be enabled, well, if they are not already activated, then You can do this using the second step command.
Let’s open Windows PowerShell or Command Prompt to start running the required commands.
To do this, right-click the Windows 10 or 11 Start button and select PowerShell (Admin) or Terminal ( Administrator), any content available.
After that, first run the following command to enable theWSL feature:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartNext, enable the virtual machine platform feature:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Re Start the computer to apply the changes.
Step 3: Install Podman on Windows 10 or 11After restarting the system again, open PowerShell as administrator and use the given TheWinget command downloads and installs RedHat Podman on Windows.
winget install RedHat.PodmanStep 4: Initialize the Podman machineOnce the installation of Podman is complete, the next step is to initialize the Podman machine, which will download the necessary files to create the container. end. In short, it will import a Linux operating system to set up WSL so that Podman can run the container natively as on any Linux machine.
podman machine initStep 5: Start the Podman MachineWhen you set up the initial setup configuration of Podman on Windows, the next step is to start the initialized machine. To do this, just type in your Windows command terminal:
podman machine startStep 6: Verify installationTo verify that Podman has been installed correctly, you can run the following command on PowerShell or CMD .
podman --versionYou should see the Podman version shown in the output. Creating ContainersPodman's command line works exactly like Docker, however, it is daemonless, which makes it different from Docker. We can use Podman commands to manage containers, images, and pods just like on Linux systems. If you're interested, you can also check out our other tutorial on installing Docker Desktop on Windows 11 or 10 via PowerShell.
So to download some container image, say Ubuntu, here is the command:
podman pull ubuntuTo check the downloaded image:
podman imagesTo quickly create a container, use:
podman run -it ubuntu /bin/bashCommands Podman commandsThe following are some common Podman commands, whose explanations are similar to those of Docker:1. Pull the image:Use Podman pull downloads container images from registries (such as Docker Hub).
podman pull ubuntu:latest
podman ps
podman ps -a
podman run -it --rm ubuntu:latest /bin/bash
podman stop container_name_or_id
podman rm container_name_or_id
podman images
podman rmi image_name
podman logs container_name_or_id
在正在运行的容器中运行命令,而无需启动新的 shell。
podman exec -it container_name_or_id /bin/bash
将容器的端口映射到主机端口。例如,这会将容器中的端口 80 映射到主机上的端口 8080。
podman run -d -p 8080:80 nginx:latest
显示 Pod 列表(Podman 用于管理容器组的概念)。
podman pod list
创建一个新容器并向其添加容器。
podman pod create --name mypod
将现有容器添加到容器。
podman pod container add mypod container_name_or_id
podman pod container remove mypod container_name_or_id
删除容器及其所有容器。
podman pod rm mypod
那些还想使用Powershell或命令提示符在Windows上删除Podman的人可以使用给定的命令:
以管理员身份运行命令终端,然后使用:
winget uninstall RedHat. Podman
The above is the detailed content of How to install Redhat Podman on Windows 10 or 11 via CMD. For more information, please follow other related articles on the PHP Chinese website!