Home  >  Article  >  How to install Redhat Podman on Windows 10 or 11 via CMD

How to install Redhat Podman on Windows 10 or 11 via CMD

WBOY
WBOYforward
2023-10-02 21:33:031143browse

Installing Red Hat Podman on Windows 11 or 10

Follow the steps below to install Red Hat Podman on a Windows machine using 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 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.

Step 2: Install WSL 2 and Virtual Machine Platform

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 the

WSL feature:

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

Re Start the computer to apply the changes.

如何通过CMD在Windows 10或11上安装Redhat Podman
Step 3: Install Podman on Windows 10 or 11

After restarting the system again, open PowerShell as administrator and use the given The

Winget command downloads and installs RedHat Podman on Windows.

winget install RedHat.Podman

如何通过CMD在Windows 10或11上安装Redhat Podman
Step 4: Initialize the Podman machine

Once 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 init

如何通过CMD在Windows 10或11上安装Redhat Podman
Step 5: Start the Podman Machine

When 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 start

Step 6: Verify installation

To verify that Podman has been installed correctly, you can run the following command on PowerShell or CMD .

podman --version

You should see the Podman version shown in the output.

Creating Containers

Podman'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 ubuntu

To check the downloaded image:

podman images

To quickly create a container, use:

podman run -it ubuntu /bin/bash

Commands Podman commands

The 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

2. List running containers:

Displays the list of currently running containers.

podman ps

3. List all containers:

Displays a list of all containers, including stopped containers.

podman ps -a

4. Run the container:

Create and start the container from the image. The -it flag allocates a terminal and makes the container interactive.

podman run -it --rm ubuntu:latest /bin/bash

5. Stop the container:

Stop a running container by specifying the container ID or name.

podman stop container_name_or_id

6. Remove a container:

Delete a stopped container by specifying the container ID or name.

podman rm container_name_or_id

7. List image:

Displays the list of locally available container images.

podman images

8. Delete image:

Delete the container image from the local repository.

podman rmi image_name

9. Container logs:

View the logs of running or stopped containers.

podman logs container_name_or_id

10. 在正在运行的容器中执行命令:

在正在运行的容器中运行命令,而无需启动新的 shell。

podman exec -it container_name_or_id /bin/bash

11. 端口映射:

将容器的端口映射到主机端口。例如,这会将容器中的端口 80 映射到主机上的端口 8080。

podman run -d -p 8080:80 nginx:latest

12. 列出窗格:

显示 Pod 列表(Podman 用于管理容器组的概念)。

podman pod list

13. 创建一个新容器:

创建一个新容器并向其添加容器。

podman pod create --name mypod

14. 将容器添加到容器:

将现有容器添加到容器。

podman pod container add mypod container_name_or_id

15. 从 Pod 中移除容器:

podman pod container remove mypod container_name_or_id

16. 删除容器:

删除容器及其所有容器。

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!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete