使用 Podman Desktop 在 Fedora Linux 上管理容器
Podman 容器
![](/data/attachment/album/202209/22/155354grmr8kku8qujbku3.jpg)



> 
> Podman Desktop 是一个开源 GUI 应用，用于在 Linux、macOS 和 Windows 上管理容器。
> 
> 
> 


从历史上看，开发人员一直使用 Docker Desktop 对容器进行图形化管理。这适用于那些安装了 Docker Daemon 和 Docker CLI 的人。然而，对于那些使用无守护进程的 Podman 工具的人来说，虽然有一些 Podman 前端，如 [Pods](https://github.com/marhkb/pods)、[Podman desktop companion](https://github.com/iongion/podman-desktop-companion) 和 [Cockpit](https://github.com/cockpit-project/cockpit/)，但没有官方应用。现在不是这种情况了。有了 Podman Desktop！


本文将讨论由红帽和其他开源贡献者开发的 Podman Desktop 的特性、安装和使用。


### 安装


要在 Fedora Linux 上安装 Podman Desktop，请访问 [podman-desktop.io](https://podman-desktop.io/)，然后单击 “Download for Linux” 按钮。你将看到两个选项：Flatpak 和 zip。在这个例子中，我们使用的是 Flatpak。单击 “Flatpak” 链接后，通过双击文件在 GNOME 软件中打开它（如果你使用的是 GNOME）。你也可以通过终端安装它：



```
flatpak install podman-desktop-X.X.X.flatpak

```

在上面的命令中，将 X.X.X 替换为你下载的特定版本。如果你下载了 zip 文件，那么解压缩存档，然后启动 Podman Desktop 应用的二进制文件。你还可以通过进入 GitHub 上项目的 [发布](https://github.com/containers/podman-desktop/releases/) 页找到预发布版本。


### 特性


Podman Desktop 仍处于早期阶段。然而，它支持许多常见的容器操作，如创建容器镜像、运行容器等。此外，你可以在 “<ruby> 首选项 <rt>  Preferences </rt></ruby>” 的 “<ruby> 扩展 <rt>  Extensions </rt></ruby>” 部分下找到 Podman 扩展，你可以使用它来管理 macOS 和 Windows 上的 Podman 虚拟机。


此外，Podman Desktop 支持 Docker Desktop 扩展。你可以在 “<ruby> 首选项 <rt>  Preferences </rt></ruby>” 下的 “Docker Desktop Extensions” 安装此类扩展。应用窗口有两个窗格。左侧窄窗格显示应用的不同功能，右侧窗格是内容区域，它将根据左侧选择的内容显示相关信息。


![Podman Desktop 0.0.6 在 Fedora 36 上运行](/data/attachment/album/202209/22/155355hb2dt2tq229n924d.png)


### 演示


为了全面了解 Podman Desktop 的功能，我们将从 Dockerfile 创建一个镜像并将其推送到注册中心，然后拉取并运行它，这一切都在 Podman Desktop 中完成。


#### 构建镜像


第一步是通过在命令行中输入以下行来创建一个简单的 Dockerfile：



```
cat <<EOF>>Dockerfile
FROM docker.io/library/httpd:2.4
COPY . /var/www/html 
WORKDIR /var/www/html 

CMD ["httpd", "-D", "FOREGROUND"]
EOF

```

现在，点击 “<ruby> 镜像 <rt>  Images </rt></ruby>” 并按下 “<ruby> 构建镜像 <rt>  Build Image </rt></ruby>” 按钮。你将被带到一个新页面以指定 Dockerfile、构建上下文和镜像名称。在 Containerfile 路径下，单击并浏览以选择你的 Dockerfile。在镜像名称下，输入镜像的名称。如果要将镜像推送到容器注册中心，那么可以以 `example.com/username/repo:tag` 形式指定完全限定的镜像名称（FQIN）。在此示例中，我输入 `quay.io/codezombie/demo-httpd:latest`，因为我在 `quay.io` 上有一个名为 `demo-httpd` 的公共仓库。你可以按照类似的格式来指定容器注册中心（Quay、Docker Hub、GitHub Container Registry 等）的 FQIN。现在，按下 “<ruby> 构建 <rt>  Build </rt></ruby>” 按钮并等待构建完成。


#### 推送镜像


构建完成后，就该推送镜像了。所以，我们需要在 Podman Desktop 中配置一个注册中心。进入 “<ruby> 首选项 <rt>  Preferences </rt></ruby>” -> “<ruby> 注册中心 <rt>  Registries </rt></ruby>” 并按下 “<ruby> 添加注册中心 <rt>  Add registry </rt></ruby>” 按钮。


![添加注册中心对话框](/data/attachment/album/202209/22/155356i2gkukyu2ujkiaky.png)


在 “<ruby> 添加注册中心 <rt>  Add registry </rt></ruby>” 对话框中，输入你的注册中心服务器地址和用户凭据，然后单击 “<ruby> 添加注册中心 <rt>  Add registry </rt></ruby>”。


现在，回到镜像列表中我的镜像，并按下上传图标将其推送到仓库。当你将鼠标悬停在设置中添加的注册中心名称开头的镜像名称上时（此演示中的 `quay.io`），镜像名称旁边会出现一个推送按钮。


![将鼠标悬停在镜像名称上时出现的按钮](/data/attachment/album/202209/22/155356jvowll6lxdcbv2sc.png)


![镜像通过 Podman Desktop 推送到仓库](/data/attachment/album/202209/22/155356uoo2rdodbo4lo7zt.png)


镜像被推送后，任何有权访问镜像仓库的人都可以拉取它。由于我的镜像仓库是公开的，因此你可以轻松地将其拉入 Podman Desktop。


#### 拉取镜像


因此，为确保一切正常，请在本地删除此镜像并将其拉入 Podman Desktop。在列表中找到镜像并按删除图标将其删除。删除镜像后，单击 “<ruby> 拉取镜像 <rt>  Pull Image </rt></ruby>” 按钮。在 “<ruby> 要拉取的镜像 <rt>  Image to Pull </rt></ruby>” 输入完全限定名称，然后按 “<ruby> 拉取镜像 <rt>  Pull Image </rt></ruby>”。


![Our container image is successfully pulled](/data/attachment/album/202209/22/155357e9jjtb2llzk9h990.png)


#### 创建一个容器


作为 Podman Desktop 演示的最后一部分，让我们从镜像中启动一个容器并检查结果。转到 “<ruby> 容器 <rt>  Containers </rt></ruby>” 并按 “<ruby> 创建容器 <rt>  Create Container </rt></ruby>”。这将打开一个包含两个选项的对话框：“<ruby> 从 Containerfile/Dockerfile <rt>  From Containerfile/Dockerfile </rt></ruby>” 和 “<ruby> 从已有镜像 <rt>  From existing image </rt></ruby>”。按下 “<ruby> 从已有镜像 <rt>  From existing image </rt></ruby>”。这将进入镜像列表。在那里，选择我们要拉取的镜像。


![在 Podman Desktop 中创建容器](/data/attachment/album/202209/22/155357fh3qz30wzxtwwfii.png)


现在，我们从列表中选择我们最近拉取的镜像，然后按它前面的 “<ruby> 运行 <rt>  Play </rt></ruby>” 按钮。在出现的对话框中，我输入 `demo-web` 作为容器名，输入 `8000` 作为端口映射，然后按下 “<ruby> 启动容器 <rt>  Start Container </rt></ruby>”。


![Container configuration](/data/attachment/album/202209/22/155357p22233u82qy2ksks.png)


容器开始运行，我们可以通过运行以下命令检查 Apache 服务器的默认页面：



```
curl http://localhost:8000

```

![可以工作！](/data/attachment/album/202209/22/155357rzt86xn0olb2069m.png)


你还应该能够在容器列表中看到正在运行的容器，其状态已更改为 “<ruby> 运行中 <rt>  Running </rt></ruby>”。在那里，你会在容器前面找到可用的操作。例如，你可以单击终端图标打开 TTY 进入到容器中！


![](/data/attachment/album/202209/22/155358bb5s8le351bbz8ss.png)


### 接下来是什么


Podman Desktop 还很年轻，处于 [积极开发](https://github.com/containers/podman-desktop) 中。 GitHub 上有一个项目 [路线图](https://github.com/orgs/containers/projects/2)，其中列出了令人兴奋的按需功能，包括：


* Kubernetes 集成
* 支持 Pod
* 任务管理器
* 卷支持
* 支持 Docker Compose
* Kind 支持




---


via: <https://fedoramagazine.org/manage-containers-on-fedora-linux-with-podman-desktop/>


作者：[Mehdi Haghgoo](https://fedoramagazine.org/author/powergame/) 选题：[lkxed](https://github.com/lkxed) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Podman Desktop is an open-source GUI application for managing containers on Linux, macOS, and Windows.

Historically, developers have been using Docker Desktop for graphical management of containers. This worked for those who had Docker Daemon and Docker CLI installed. However, for those who used Podman daemon-less tool, although there were a few Podman frontends like [Pods](https://github.com/marhkb/pods), [Podman desktop companion](https://github.com/iongion/podman-desktop-companion), and [Cockpit](https://github.com/cockpit-project/cockpit/), there was no official application. This is not the case anymore. Enter Podman Desktop!

This article will discuss features, installation, and use of Podman Desktop, which is developed by developers from Red Hat and other open-source contributors.

## Installation

To install Podman Desktop on Fedora Linux, head over to [podman-desktop.io](https://podman-desktop.io/), and click the *Download for Linux* button. You will be presented with two options: Flatpak and zip. In this example we are using Flatpak. After clicking *Flatpak*, open it in GNOME Software by double clicking the file (if you are using GNOME). You can also install it via the terminal:

flatpak install podman-desktop-X.X.X.flatpak

In the above command, replace X.X.X with the specific version you have downloaded. If you downloaded the zip file, then extract the archive, and launch the *Podman Desktop* application binary. You can also find pre-release versions by going to the project’s [releases](https://github.com/containers/podman-desktop/releases/) page on GitHub.

## Features

Podman Desktop is still in its early days. Yet, it supports many common container operations like creating container images, running containers, etc. In addition, you can find a Podman extension under Extensions Catalog in Preferences, which you can use to manage Podman virtual machines on macOS and Windows. Futhermore, Podman Desktop has support for Docker Desktop extensions.

You can install such extensions in the Docker Desktop Extensions section under Preferences. The application window has two panes. The left narrow pane shows different features of the application and the right pane is the content area, which will display relevant information given what is selected on the left.

![](https://fedoramagazine.org/wp-content/uploads/2022/08/pd-1024x539.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/pd-1024x539.png)

## Demo

To get an overall view of Podman Desktop’s capabilities, we will create an image from a Dockerfile and push it to a registry, then pull and run it, all from within Podman Desktop.

### Build image

The first step is to create a simple Dockerfile by entering the following lines in the command line:

cat <<EOF>>Dockerfile FROM docker.io/library/httpd:2.4 COPY . /var/www/html WORKDIR /var/www/html CMD ["httpd", "-D", "FOREGROUND"] EOF

Now, go to the Images section and press the Build Image button. You will be taken to a new page to specify the Dockerfile, build context and image name. Under Containerfile path, click and browse to pick your Dockerfile. Under image name, enter a name for your image. You can specify a fully qualified image name (FQIN) in the form `example.com/username/repo:tag` if you want to push the image to a container registry. In this example, I enter `quay.io/codezombie/demo-httpd:latest`, because I have a public repository named demo-httpd on quay.io. You can follow a similar format to specify your FQIN pointing to your container registry (Quay, Docker Hub, GitHub Container Registry, etc.). Now, press *Build* and wait for the build to complete.

### Push image

Once the build is finished, it’s time to push the image. So, we need to configure a registry in Podman Desktop. Go to Preferences, Registries and press *Add registry.*

![](https://fedoramagazine.org/wp-content/uploads/2022/08/registry.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/registry.png)

In the Add Registry dialog, enter your registry server address, and your user credentials and click ADD REGISTRY.

Now, I go back to my image in the list of images and push it to the repository by pressing the upload icon. When you hover over the image name that starts with the name of the registry added in the settings (quay.io in this demo), a push button appears alongside the image name.

![](https://fedoramagazine.org/wp-content/uploads/2022/08/Screenshot-from-2022-08-27-23-51-38.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/Screenshot-from-2022-08-27-23-51-38.png)

Once the image is pushed, anyone with access to the image repository can pull it. Since my image repository is public, you can easily pull it in Podman Desktop.

### Pull image

So, to make sure things work, remove this image locally and pull it in Podman Desktop. Find the image in the list and remove it by pressing the *delete* icon. Once the image is removed, click the *Pull Image* button. Enter the fully qualified name in the *Image to Pull* section and press *Pull image*.

![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-2.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-2.png)

### Create a container

As the last part in our Podman Desktop demo, let us spin up a container from our image and check the result. I go to *Containers* and press *Create Container*. This will open up a dialog with two choices: *From Containerfile/Dockerfile*, and *From existing image*. Press *From existing image*. This takes us to the list of images. There, select the image we pulled.

![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-3.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-3.png)

Now, we select our recently-pulled image from the list and press the *Play* button in front of it. In the dialog that appears, I enter demo-web as *Container Name* and 8000 as *Port Mapping*, and press *Start Container*.

![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-5.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-5.png)

The container starts running and we can check out our Apache server’s default page by running the following command:

curl http://localhost:8000

![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-6.png)


![](https://fedoramagazine.org/wp-content/uploads/2022/08/image-6.png)

You should also be able to see the running container in the Containers list, with its status changed to *Running*. There, you will find available operations in front of the container. For example, you can click the terminal icon to open a TTY into the container!

![](https://fedoramagazine.org/wp-content/uploads/2022/09/image-2-1024x393.png)

## What Comes Next

Podman Desktop is still young and under [active development](https://github.com/containers/podman-desktop). There is a project [roadmap](https://github.com/orgs/containers/projects/2) on GitHub with a list of exciting and on-demand features including:

- Kubernetes Integration
- Support for Pods
- Task Manager
- Volumes Support
- Support fo Docker Compose
- Kind Support

## Kevin Degeling

So cool.

I wrote an article about running Docker on Fedora, two years ago. Back then, there were many issues to work around, and Podman wasn’t really really ready for the spotlight. Now we have Podman Desktop and Rancher Desktop and suddenly we never have to look back at those dark times!

What is also very important about Podman Desktop, is that it’s cross platform. Don’t forget to migrate your entire team away from Docker Desktop… before they’ll make you pay a per-seat license 😉

## Mehdi Haghgoo

Yeah it’s very nice!

I guess many developers have been waiting for Podman Desktop like us.

I’m hearing about Rancher Desktop for the first time, though.

## Karlis K.

This is great! 🥳

Up until now I relied on Cockpit, but this just takes the cake!

## Mehdi Haghgoo

Yeah, awesome.

Furthermore, Cockpit’s Podman plugin was quite limited.

## Karlis K.

Also, you can install the Flatpak with just:

## Mehdi Haghgoo

Sure, thank you.

However, pre-release builds should still be installed manually.

## Scott

I believe the project below is much more interesting because it uses GTK4 and Libadwaita. By doing so, it really integrates nicely with the GNOME desktop.

Pods

https://github.com/marhkb/pods

## Mehdi Haghgoo

I am not sure if Pods is cross-platform like Podman Desktop.

## Scott

No, it’s only designed for the Linux (GNOME) desktop (it uses GTK4/Libadwaita).

## Scott

A simple GUI application around Toolbx would also be very interesting!

Toolbx

https://containertoolbx.org/

## Mehdi Haghgoo

Right, it would be nice to have a graphical interface to Toolbox on OSTree-based OSes. I don’have much experience with these distributions though. So, maybe someone more experienced can probably write a good article about using Toolbox on Fedora and if there are any GUI interfaces for it.

## Scott

To criticize my own idea: it basically wouldn’t be much more than a wrapper around a terminal (because in the end, when you want to edit something, you will need a terminal).

But you could create a gui for creating, entering and deleting new toolboxes.

## kaosine

Do wish it was possible to use toolbox or an alternative for that existed. Heck, I just wanted to use this to pull even just fedora official images, but it seems to think I’m not authorized after logging in to quay. I should be able to pull images no issue I would think that aren’t my own…

## Mehdi Haghgoo

Did you use the latest version of Podman Desktop? You could also download the latest pre-release versions from https://github.com/containers/podman-desktop/releases.