Windows 安裝 Podman Desktop

簡介: Podman(POD MANager) 是一個用於管理容器和映像、掛載到這些容器中的卷以及由容器組組成的 pod 的工具。Podman 在 Linux 上運行容器,但也可以使用 Podman 管理的虛擬機在 Mac 和 Windows 系統上使用。 Podman 基於 libpod,libpod 是一個用於容器生命週期管理的庫,也包含在此存儲庫中。libpod 庫提供了用於管理 containers(容器)、pods、 container images(容器鏡像)和 volumes(卷)的 API。

podman 簡介

Podman:用於管理 OCI 容器和 Pod 的工具
Podman: A tool for managing OCI containers and pods

 

 

Podman(POD MANager) 是一個用於管理容器和映像、掛載到這些容器中的卷以及由容器組組成的 pod 的工具。Podman 在 Linux 上運行容器,但也可以使用 Podman 管理的虛擬機在 Mac 和 Windows 系統上使用。 Podman 基於 libpodlibpod 是一個用於容器生命週期管理的庫,也包含在此存儲庫中。libpod 庫提供了用於管理 containers(容器)、pods、 container images(容器鏡像)和 volumes(卷)的 API

概述和範圍

在高層次上,Podman 和 libpod 的範圍如下:

  • 支持多種容器鏡像格式,包括 OCI 和 Docker 鏡像。
  • 全面管理這些映像,包括從各種來源拉取(包括信任和驗證)、創建(通過 Containerfile 或 Dockerfile 構建或從容器提交)以及推送到註冊表和其他存儲後端。
  • 容器生命週期的全面管理,包括創建(從映像和鬆散的根文件系統)、運行、檢查點和恢復(通過 CRIU)以及刪除。
  • 使用 Netavark 全面管理容器網絡。
  • 支持 Pod,即共享資源並一起管理的容器組。
  • 支持在沒有 root 或其他提升權限的情況下運行容器和 Pod
  • 容器和 Pod 的資源隔離。
  • 支持 Docker 兼容的 CLI 接口,該接口既可以在本地運行容器,也可以在遠程系統上運行容器。
  • 無管理器守護進程,以提高安全性並降低空閒時的資源利用率。
  • 支持 REST API,提供與 Docker 兼容的接口和公開高級 Podman 功能的改進接口。
  • 支持通過 podman machine 運行的虛擬機在 Windows 和 Mac 上運行。

Roadmap 路線圖

  1. 功能齊全的 GUI 前端,用於 podman machine
  2. 進一步改進和 podman generate kubepodman play kube
  3. 對 Pod 的改進,包括添加 Pod 級別的資源限制

Rootless 無根

Podman 可以作爲普通用戶輕鬆運行,不需要 setuid 二進制文件。 在沒有 root 的情況下運行時,Podman 容器使用用戶命名空間將容器中的 root 設置爲運行 Podman 的用戶。 Rootless Podman 運行鎖定的容器,沒有運行容器的用戶沒有的權限。 其中一些限制可以解除(例如,通過),但無根容器永遠不會擁有比啓動它們的用戶更多的權限。 如果您以用戶身份運行 Podman 並從主機掛載,您仍然無法更改它,因爲您的用戶沒有這樣做的權限。--privileged/etc/passwd

幾乎所有正常的 Podman 功能都可用,儘管存在一些 缺點。 任何最近的 Podman 版本都應該能夠在沒有任何額外配置的情況下運行無根,儘管您的操作系統可能需要安裝 指南 中詳述的一些額外配置。

在使用無根 Podman 之前,管理員需要進行一些配置,此處 記錄了必要的設置。

podman 安裝說明

Podman for Windows

雖然“容器是Linux”,但 Podman 也可以在 Mac 和 Windows 上運行。 它提供本機 CLI 並嵌入要啓動的來賓 Linux 系統 您的容器。此來賓被稱爲 Podman 機器,並且是 使用命令進行管理。在 Windows 上,每個 Podman 機器由虛擬化的 Windows 子系統支持 Linux (WSLv2) 分發。podman 命令可以直接從你的 Windows PowerShell(或CMD)提示符,它與在 WSL 環境中運行的 podman 服務。或者,您 如果您更喜歡 Linux,可以直接從 WSL 實例訪問 Podman 提示和 Linux 工具。除了命令行訪問之外,Podman 同時偵聽 Docker API 客戶端,支持直接使用 基於 Docker 的工具和從您的語言進行編程訪問 選擇。podman machine

前置條件

由於 Podman 使用 WSL,因此您需要最新版本的 Windows 10 或 Windows 11 在 x64 上,WSL 需要內部版本 18362 或更高版本,arm64 系統需要內部版本 19041 或更高。在內部,WSL 使用 虛擬化,因此您的系統必須支持並具有硬件 已啓用虛擬化。如果在 VM 上運行 Windows,則必須具有支持嵌套虛擬化的 VM

還建議安裝現代的 “Windows終端”, 它提供了優於標準 PowerShell 的用戶體驗,並且 CMD 提示,以及 WSL 提示,如果需要的話。

你可以通過搜索 Windows 應用商店或運行 以下命令:winget

winget install Microsoft.WindowsTerminal

安裝 podman

下載地址,https://github.com/containers/podman/releases

安裝 Windows Podman 客戶端首先要下載 Podman Windows installer(安裝程序)。Windows 安裝程序是隨每個 Podman 版本構建的,可以從 Github 官方發佈頁面下載。請確保下載本指南中討論的功能的 4.5.1 或更高版本。

 

下載後,只需運行該文件,然後重新啓動一個新的終端。在這一點之後,podman.exe 將出現在您的 PATH 上,您將能夠運行該命令來創建您的第一臺計算機。

podman machine init

自動 WSL 安裝

如果您的系統上尚未安裝 WSL,則第一個 machine init 命令將提示一個對話框以開始自動安裝。如果接受,此過程將安裝必要的 Windows 組件,重新啓動系統,並在登錄後在 終端窗口 中重新啓動計算機創建過程。請確保等待一兩分鐘以重新啓動,因爲 Windows 在執行啓動項目之前會有延遲。或者,您可以拒絕自動安裝並手動安裝 WSL。但是,這將需要額外的下載和設置時間。

機器初始化過程

安裝 WSL 後,init 命令將安裝一個最小化的 Fedora,並對其進行自定義以運行 podman

Downloading VM image: fedora-podman-amd64-v37.0.38.tar.xz: done
Extracting compressed file
Importing operating system into WSL (this may take a few minutes on a new WSL install)...
正在導入,這可能需要幾分鐘時間。
操作成功完成。
Configuring system...
Generating public/private ed25519 key pair.
Your identification has been saved in podman-machine-default
Your public key has been saved in podman-machine-default.pub
The key fingerprint is:
SHA256:eq+hsYHASu6jvSZZncjqQpi6K+a2KCAlgmQQmwr1pCg root@master-jeff
The key's randomart image is:
|+.. .            |
| B +             |
|E . .            |
|B..              |
|+*oo .  S        |
|Bo+.o. .         |
|*=  . + o        |
|@=.    * o       |
|#X=.  o ...      |
+----[SHA256]-----+
Machine init complete
To start your machine run:

        podman machine start

啓動 machine

machine 初始化過程完成後,可以根據需要啓動和停止:

Starting machine "podman-machine-default"

This machine is currently configured in rootless mode. If your containers
require root permissions (e.g. ports < 1024), or if you run into compatibility
issues with non-podman clients, you can switch using the following command:

        podman machine set --rootful

API forwarding listening on: npipe:////./pipe/docker_engine

Docker API clients default to this address. You do not need to set DOCKER_HOST.
Machine "podman-machine-default" started successfully

此計算機當前配置爲無根(rootless)模式。如果您的容器需要 root 權限(例如端口 < 1024),或者如果遇到兼容性問題
對於非 podman 客戶端的問題,可以使用以下命令進行切換:podman machine set --rootful

Rootful & Rootless

在嵌入式 WSL Linux 發行版上,podman 可以在根用戶(rootful)或非特權用戶(rootless)下運行。爲了在 Linux 上與 Podman 保持行爲一致性,無根是默認設置。

注意:有根(rootful)容器和無根(rootless)容器是不同的,並且彼此隔離。針對其中一個的 Podman 命令(例如,Podman-ps)不會代表另一個的結果/狀態。

雖然大多數容器在無根(rootless)設置中運行良好,但您可能會發現容器僅在具有根權限的情況下運行。如果是這種情況,您可以通過停止機器並使用 set 命令將其切換到 rootful

podman machine stop
podman machine set --rootful

要恢復無根(rootless)執行,請將 rootful 設置爲 false

Podman machine stop
Podman machine set --rootful=false

安裝 podman desktop

  1. 訪問官網的 desktop下載地址:https://podman-desktop.io

 

 

  1. 使用 Windows 安裝程序靜默安裝 Podman Desktophttps://podman-desktop.io/docs/installation/windows-install/installing-podman-desktop-silently-with-the-windows-installer

 

考慮使用此方法在沒有用戶交互的情況下安裝 Podman Desktop Windows 安裝程序。

執行步驟:

  • 下載 Windows 安裝程序。
  • 運行 PowerShell 命令:
Start-Process -FilePath '.\podman-desktop-0.10.0-setup.exe' -ArgumentList "\S" -Wait

 

此處我是用 winget 命令,在命令行中執行 podman desktop 安裝:

winget install -e --id RedHat.Podman-Desktop

 

已找到 Podman Desktop [RedHat.Podman-Desktop] 版本 1.1.0
此應用程序由其所有者授權給你。
Microsoft 對第三方程序包概不負責,也不向第三方程序包授予任何許可證。
正在下載 https://github.com/containers/podman-desktop/releases/download/v1.1.0/podman-desktop-1.1.0-setup.exe
  ██████████████████████████████   113 MB /  113 MB
已成功驗證安裝程序哈希
正在啓動程序包安裝...
已成功安裝

此時桌面已經出現 Podman Desktop 圖標,點擊運行界面展示如下:

  • podman desktop dashboard

 

  • podman desktop containers

 

  • podman desktop pods

 

  • podman desktop images

 

  • podman desktop volumes

podman desktop volumes

 

podman 命令介紹

基本上每個命令的使用都可以使用 podman [options] [command] -h 套路查看更多信息。

podman -h

Manage pods, containers and images

Usage:
  podman.exe [options] [command]

Available Commands:
  attach      Attach to a running container
  build       Build an image using instructions from Containerfiles
  commit      Create new image based on the changed container
  container   Manage containers
  cp          Copy files/folders between a container and the local filesystem
  create      Create but do not start a container
  diff        Display the changes to the object's file system
  events      Show podman system events
  exec        Run a process in a running container
  export      Export container's filesystem contents as a tar archive
  generate    Generate structured data based on containers, pods or volumes
  healthcheck Manage health checks on containers
  help        Help about any command
  history     Show history of a specified image
  image       Manage images
  images      List images in local storage
  import      Import a tarball to create a filesystem image
  info        Display podman system information
  init        Initialize one or more containers
  inspect     Display the configuration of object denoted by ID
  kill        Kill one or more running containers with a specific signal
  kube        Play containers, pods or volumes from a structured file
  load        Load image(s) from a tar archive
  login       Login to a container registry
  logout      Logout of a container registry
  logs        Fetch the logs of one or more containers
  machine     Manage a virtual machine
  manifest    Manipulate manifest lists and image indexes
  network     Manage networks
  pause       Pause all the processes in one or more containers
  pod         Manage pods
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image from a registry
  push        Push an image to a specified destination
  rename      Rename an existing container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Removes one or more images from local storage
  run         Run a command in a new container
  save        Save image(s) to an archive
  search      Search registry for image
  secret      Manage secrets
  start       Start one or more containers
  stats       Display a live stream of container resource usage statistics
  stop        Stop one or more containers
  system      Manage podman
  tag         Add an additional name to a local image
  top         Display the running processes of a container
  unpause     Unpause the processes in one or more containers
  untag       Remove a name from a local image
  update      update an existing container
  version     Display the Podman version information
  volume      Manage volumes
  wait        Block on one or more containers

Options:
  -c, --connection string         Connection to use for remote Podman service (default "podman-machine-default")
      --help                      Help for podman
      --identity string           path to SSH identity file, (CONTAINER_SSHKEY) (default "C:\\Users\\Jeffery.Chai\\.ssh\\podman-machine-default")
      --log-level string          Log messages above specified level (trace, debug, info, warn, warning, error, fatal, panic) (default "warn")
      --noout                     do not output to stdout
      --ssh string                define the ssh mode (default "golang")
      --storage-opt stringArray   Used to pass an option to the storage driver
      --url string                URL to access Podman service (CONTAINER_HOST) (default "ssh://[email protected]:61683/run/user/1000/podman/podman.sock")
  -v, --version                   version for podman.exe

podman machine -h

Manage a virtual machine

Description:
  Manage a virtual machine. Virtual machines are used to run Podman.

Usage:
  podman.exe machine [command]

Available Commands:
  info        Display machine host info
  init        Initialize a virtual machine
  inspect     Inspect an existing machine
  list        List machines
  os          Manage a Podman virtual machine's OS
  rm          Remove an existing machine
  set         Sets a virtual machine setting
  ssh         SSH into an existing machine
  start       Start an existing machine
  stop        Stop an existing machine

更多詳細信息,請自行安裝嘗試,趕快動手實踐喲!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章