如何在mac上安裝podman

安裝 Podman 在 macOS 上

在 macOS 上安裝 Podman 需要使用 Podman 的桌面客戶端工具 Podman Desktop 或通過 Homebrew 安裝命令行工具。

使用 Homebrew 安裝 Podman:

(base) ninjamac@ninjamacdeMacBook-Air shell % brew install podman
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 3 taps (kong/deck, homebrew/core and homebrew/cask).
==> New Formulae
clang-include-graph             claude-squad                    kargo
==> New Casks
firezone                passepartout            simpledemviewer         slideshowerYou have 46 outdated formulae installed.==> Downloading https://ghcr.io/v2/homebrew/core/podman/manifests/5.5.0
######################################################################################## 100.0%
==> Fetching podman
==> Downloading https://ghcr.io/v2/homebrew/core/podman/blobs/sha256:8326e41b43e41f71fa6cf9c321
######################################################################################## 100.0%
==> Pouring podman--5.5.0.arm64_sequoia.bottle.tar.gz
==> Caveats
In order to run containers locally, podman depends on a Linux kernel.
One can be started manually using `podman machine` from this package.
To start a podman VM automatically at login, also install the cask
"podman-desktop".zsh completions have been installed to:/opt/homebrew/share/zsh/site-functions
==> Summary
🍺  /opt/homebrew/Cellar/podman/5.5.0: 202 files, 79.3MB
==> Running `brew cleanup podman`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`)

安裝完成后初始化 Podman 虛擬機(由于 macOS 不支持 Linux 容器原生運行,Podman 會創建一個輕量級虛擬機來運行容器):

(base) ninjamac@ninjamacdeMacBook-Air shell % podman machine init
Looking up Podman Machine image at quay.io/podman/machine-os:5.5 to create VM
Getting image source signatures
Copying blob d8d46037edd8 done   | 
Copying config 44136fa355 done   | 
Writing manifest to image destination
d8d46037edd878510cbcaabb4878e59e5d9eaa98d0c73eef883cd98491b08e96
Extracting compressed file: podman-machine-default-arm64.raw: done  
Machine init complete

啟動 Podman 虛擬機:

(base) ninjamac@ninjamacdeMacBook-Air shell % podman machine start
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 --rootfulAPI forwarding listening on: /var/folders/_0/8glqp3v96vx0_rzhlqb8g3xr0000gn/T/podman/podman-machine-default-api.sockThe system helper service is not installed; the default Docker API socket
address can't be used by podman. If you would like to install it, run the following commands:sudo /opt/homebrew/Cellar/podman/5.5.0/bin/podman-mac-helper installpodman machine stop; podman machine startYou can still connect Docker API clients by setting DOCKER_HOST using the
following command in your terminal session:export DOCKER_HOST='unix:///var/folders/_0/8glqp3v96vx0_rzhlqb8g3xr0000gn/T/podman/podman-machine-default-api.sock'Machine "podman-machine-default" started successfully

驗證 Podman 是否正確安裝:

(base) ninjamac@ninjamacdeMacBook-Air shell % podman version
Client:        Podman Engine
Version:       5.5.0
API Version:   5.5.0
Go Version:    go1.24.3
Built:         Wed May 14 02:59:13 2025
Build Origin:  brew
OS/Arch:       darwin/arm64Server:       Podman Engine
Version:      5.5.0
API Version:  5.5.0
Go Version:   go1.23.8
Git Commit:   0dbcb51477ee7ab8d3b47d30facf71fc38bb0c98
Built:        Tue May 13 08:00:00 2025
OS/Arch:      linux/arm64(base) ninjamac@ninjamacdeMacBook-Air shell % podman info   
Client:APIVersion: 5.5.0BuildOrigin: brewBuilt: 1747162753BuiltTime: Wed May 14 02:59:13 2025GitCommit: ""GoVersion: go1.24.3Os: darwinOsArch: darwin/arm64Version: 5.5.0
host:arch: arm64buildahVersion: 1.40.0cgroupControllers:- cpu- io- memory- pidscgroupManager: systemdcgroupVersion: v2conmon:package: conmon-2.1.12-3.fc41.aarch64path: /usr/bin/conmonversion: 'conmon version 2.1.12, commit: 'cpuUtilization:idlePercent: 99.56systemPercent: 0.27userPercent: 0.17cpus: 4databaseBackend: sqlitedistribution:distribution: fedoravariant: coreosversion: "41"eventLogger: journaldfreeLocks: 2045hostname: localhost.localdomainidMappings:gidmap:- container_id: 0host_id: 1000size: 1- container_id: 1host_id: 100000size: 1000000uidmap:- container_id: 0host_id: 501size: 1- container_id: 1host_id: 100000size: 1000000kernel: 6.12.13-200.fc41.aarch64linkmode: dynamiclogDriver: journaldmemFree: 1293139968memTotal: 2042273792networkBackend: netavarknetworkBackendInfo:backend: netavarkdns:package: aardvark-dns-1.14.0-1.fc41.aarch64path: /usr/libexec/podman/aardvark-dnsversion: aardvark-dns 1.14.0package: netavark-1.14.0-1.fc41.aarch64path: /usr/libexec/podman/netavarkversion: netavark 1.14.0ociRuntime:name: crunpackage: crun-1.20-2.fc41.aarch64path: /usr/bin/crunversion: |-crun version 1.20commit: 9c9a76ac11994701dd666c4f0b869ceffb599a66rundir: /run/user/501/crunspec: 1.0.0+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJLos: linuxpasta:executable: /usr/bin/pastapackage: passt-0^20250121.g4f2c8e7-2.fc41.aarch64version: |pasta 0^20250121.g4f2c8e7-2.fc41.aarch64-pastaCopyright Red HatGNU General Public License, version 2 or later<https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law.remoteSocket:exists: truepath: unix:///run/user/501/podman/podman.sockrootlessNetworkCmd: pastasecurity:apparmorEnabled: falsecapabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOTrootless: trueseccompEnabled: trueseccompProfilePath: /usr/share/containers/seccomp.jsonselinuxEnabled: trueserviceIsRemote: trueslirp4netns:executable: /usr/bin/slirp4netnspackage: slirp4netns-1.3.1-1.fc41.aarch64version: |-slirp4netns version 1.3.1commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236libslirp: 4.8.0SLIRP_CONFIG_VERSION_MAX: 5libseccomp: 2.5.5swapFree: 0swapTotal: 0uptime: 0h 38m 35.00svariant: v8
plugins:authorization: nulllog:- k8s-file- none- passthrough- journaldnetwork:- bridge- macvlan- ipvlanvolume:- local
registries:search:- docker.io
store:configFile: /var/home/core/.config/containers/storage.confcontainerStore:number: 3paused: 0running: 1stopped: 2graphDriverName: overlaygraphOptions: {}graphRoot: /var/home/core/.local/share/containers/storagegraphRootAllocated: 106415992832graphRootUsed: 4448870400graphStatus:Backing Filesystem: xfsNative Overlay Diff: "true"Supports d_type: "true"Supports shifting: "false"Supports volatile: "true"Using metacopy: "false"imageCopyTmpDir: /var/tmpimageStore:number: 1runRoot: /run/user/501/containerstransientStore: falsevolumePath: /var/home/core/.local/share/containers/storage/volumes
version:APIVersion: 5.5.0BuildOrigin: 'Copr: packit/containers-podman-26126'Built: 1747094400BuiltTime: Tue May 13 08:00:00 2025GitCommit: 0dbcb51477ee7ab8d3b47d30facf71fc38bb0c98GoVersion: go1.23.8Os: linuxOsArch: linux/arm64Version: 5.5.0

配置 Podman 環境

Podman 在 macOS 上運行需要依賴虛擬機,默認使用 QEMU 運行輕量級 Linux 環境。可以通過以下命令調整虛擬機配置:

調整虛擬機 CPU 和內存(可選):

podman machine stop
podman machine set --cpus 4 --memory 8192
podman machine start

運行容器

運行一個簡單的測試容器(例如 Nginx):

podman run -d -p 8080:80 --name nginx docker.io/library/nginx

驗證容器是否運行:

(base) ninjamac@ninjamacdeMacBook-Air shell % podman ps               
CONTAINER ID  IMAGE                           COMMAND               CREATED         STATUS         PORTS                 NAMES
88288e7b6232  docker.io/library/nginx:latest  nginx -g daemon o...  58 seconds ago  Up 58 seconds  0.0.0.0:8080->80/tcp  nginx

訪問運行中的容器服務(在瀏覽器中打開 http://localhost:8080)。

管理容器和鏡像

列出本地所有鏡像:

podman images

從 Docker Hub 拉取鏡像:

podman pull ubuntu:latest

進入運行中的容器:

(base) ninjamac@ninjamacdeMacBook-Air shell % podman exec -it nginx /bin/bash
root@88288e7b6232:/# 

停止和刪除容器:

podman stop nginx
podman rm nginx

構建自定義鏡像

創建一個簡單的 Dockerfile:

FROM alpine:latest
RUN apk add --no-cache python3
CMD ["python3", "--version"]

使用 Podman 構建鏡像:

(base) ninjamac@ninjamacdeMacBook-Air podman % podman build -t my-python-images .
STEP 1/3: FROM alpine:latest
Resolved "alpine" as an alias (/etc/containers/registries.conf.d/000-shortnames.conf)
Trying to pull docker.io/library/alpine:latest...
Getting image source signatures
Copying blob sha256:d69d4d41cfe2ee680d6972795e2a1eb9e4dc4ec3b3c5e0797c9ab43bb3726fa7
Copying config sha256:2abc5e83407155714f171c293f197e1310176959e106f8ad63ffa2e7e9635d4a
Writing manifest to image destination
STEP 2/3: RUN apk add --no-cache python3
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/main/aarch64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/community/aarch64/APKINDEX.tar.gz
(1/17) Installing libbz2 (1.0.8-r6)
(2/17) Installing libexpat (2.7.1-r0)
(3/17) Installing libffi (3.4.8-r0)
(4/17) Installing gdbm (1.24-r0)
(5/17) Installing xz-libs (5.8.1-r0)
(6/17) Installing libgcc (14.2.0-r6)
(7/17) Installing libstdc++ (14.2.0-r6)
(8/17) Installing mpdecimal (4.0.1-r0)
(9/17) Installing ncurses-terminfo-base (6.5_p20250503-r0)
(10/17) Installing libncursesw (6.5_p20250503-r0)
(11/17) Installing libpanelw (6.5_p20250503-r0)
(12/17) Installing readline (8.2.13-r1)
(13/17) Installing sqlite-libs (3.49.2-r0)
(14/17) Installing python3 (3.12.11-r0)
(15/17) Installing python3-pycache-pyc0 (3.12.11-r0)
(16/17) Installing pyc (3.12.11-r0)
(17/17) Installing python3-pyc (3.12.11-r0)
Executing busybox-1.37.0-r18.trigger
OK: 49 MiB in 33 packages
--> 48a838f69aa8
STEP 3/3: CMD ["python3", "--version"]
COMMIT my-python-images
--> daf80a07597c
Successfully tagged localhost/my-python-images:latest
daf80a07597cfe6a88325506732ce1fd95a10a3fe9c44b38f0ea7a512bc1d5c9
(base) ninjamac@ninjamacdeMacBook-Air podman % podman images
REPOSITORY                  TAG         IMAGE ID      CREATED        SIZE
localhost/my-python-images  latest      daf80a07597c  8 seconds ago  53.8 MB
docker.io/library/alpine    latest      2abc5e834071  4 days ago     8.81 MB
docker.io/library/nginx     latest      997e7f255061  6 weeks ago    202 MB

運行自定義鏡像:

podman run --rm my-python-image

持久化存儲和數據卷

創建一個數據卷并掛載到容器:

podman volume create my_volume
podman run -d -v my_volume:/data --name volume_test alpine tail -f /dev/null

進入容器驗證數據卷:

podman exec -it volume_test /bin/sh

網絡配置

創建一個自定義網絡:

(base) ninjamac@192 xx % podman network create my_network
my_network

運行容器并使用自定義網絡:

podman run -d --network my_network --name web nginx
podman run -it --network my_network --name client alpine ping web

調試和日志檢查

查看容器日志:

podman logs nginx

檢查容器詳細配置:

podman inspect nginx

監控容器資源使用:

(base) ninjamac@192 xx % podman statsID            NAME         CPU %       MEM USAGE / LIMIT  MEM %       NET IO             BLOCK IO    PIDS        CPU TIME    AVG CPU %
b059483e17f4  volume_test  0.01%       53.25kB / 2.042GB  0.00%       3.006kB / 1.398kB  0B / 0B     1           1.564638s   0.01%

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/pingmian/84104.shtml
繁體地址,請注明出處:http://hk.pswp.cn/pingmian/84104.shtml
英文地址,請注明出處:http://en.pswp.cn/pingmian/84104.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

QGraphicsView中鼠標點擊與移動事件傳遞給MainWindow

在Qt圖形應用程序開發中,QGraphicsView和QGraphicsScene框架提供了強大的2D圖形顯示功能。然而,當我們需要在主窗口(MainWindow)中處理這些視圖中的鼠標事件。 問題背景 在典型的Qt圖形應用程序架構中: MainWindow └── QGraphicsView└── QGraphicsScene└── QGra…

Spring Boot 緩存注解詳解:@Cacheable、@CachePut、@CacheEvict(超詳細實戰版)

&#x1f4a1; 前言 在高并發、高性能的系統開發中&#xff0c;緩存是提升接口響應速度和降低數據庫壓力的重要手段。Spring Boot 提供了強大的緩存抽象層 —— spring-context-support&#xff0c;并結合 JSR-107 標準&#xff0c;提供了多個緩存注解&#xff0c;如&#xff…

vue中ref的詳解以及react的ref對比

文章目錄 1. ref是什么2. ref的使用3. ref的特性4. 使用場景5. 注意事項6. 與 React 的對比7. 動態 ref8. 函數式組件中的 ref9. 組合式 API 中的 ref10. 總結 1. ref是什么 ref 被用來給元素或子組件注冊引用信息。引用信息將會注冊在父組件的 $refs 對象上。可以通過實例對象…

通過ca證書的方式設置允許遠程訪問Docker服務

設置允許遠程訪問Docker服務 使用場景 環境 系統&#xff1a;anolis7.9 修改Docker服務配置&#xff0c;配置安全證書 生成ca證書到/etc/docker目錄中&#xff0c;后續會要用到 #該步驟需要設置密碼&#xff0c;后面步驟會要用到&#xff0c;此處設置密碼為123456 openss…

Qt Quick Layout功能及架構

Qt Quick Layouts 是 Qt Quick 中用于管理用戶界面布局的模塊&#xff0c;在 Qt 6.0 中繼續提供強大的布局管理功能。 一、主要功能 主要布局類型 RowLayout - 水平排列項目 ColumnLayout - 垂直排列項目 GridLayout - 網格排列項目 StackLayout - 堆疊項目&#xff08;一…

Golang 面試經典題:map 的 key 可以是什么類型?哪些不可以?

Golang 面試經典題&#xff1a;map 的 key 可以是什么類型&#xff1f;哪些不可以&#xff1f; 在 Golang 的面試中&#xff0c;map 類型的使用是一個常見的考點&#xff0c;其中對 key 類型的合法性 是一道常被提及的基礎卻很容易被忽視的問題。本文將帶你深入理解 Golang 中…

從 ClickHouse、Druid、Kylin 到 Doris:網易云音樂 PB 級實時分析平臺降本增效

網易云音樂基于 Apache Doris 替換了早期架構中 Kylin、Druid、Clickhouse、Elasticsearch、HBase 等引擎&#xff0c;統一了實時分析架構&#xff0c;并廣泛應用于廣告實時數倉、日志平臺和會員報表分析等典型場景中&#xff0c;帶來導入性能提升 3&#xff5e;30 倍&#xff…

Android 本地存儲路徑說明

一、背景 作為一個開發者,我們經常需要通過緩存一些文件到SD卡中,常見的方式就是,通過: File sdCard Environment.getExternalStorageDirectory(); 獲取SD卡根目錄,然后自定義文件/文件名進行文件存儲.這樣做法的結果就是,當手機安裝了大量的app時&#xff0c;SD卡根目錄會…

開發的幾種格式,TCP的十個重要機制

自定義協議中&#xff0c; 我們有幾種常見的數據格式&#xff1a; 1.xml 通過標簽來組織數據 請求&#xff1a; 優勢&#xff1a; 讓數據的可讀性變更好了 劣勢&#xff1a; 標簽非常繁瑣&#xff0c;傳輸的時候也占用更多網絡帶寬&#xff08;maven會使用xml來管理項目配…

dify打造數據可視化圖表

一、概述 在日常工作和學習中&#xff0c;我們經常需要和數據打交道。無論是分析報告、項目展示&#xff0c;還是簡單的數據洞察&#xff0c;一個清晰直觀的圖表&#xff0c;往往能勝過千言萬語。 一款能讓數據可視化變得超級簡單的 MCP Server&#xff0c;由螞蟻集團 AntV 團隊…

自然語言處理——文本分類

文本分類 傳統機器學習方法文本表示向量空間模型 特征選擇文檔頻率互信息信息增益&#xff08;IG&#xff09; 分類器設計貝葉斯理論&#xff1a;線性判別函數 文本分類性能評估P-R曲線ROC曲線 將文本文檔或句子分類為預定義的類或類別&#xff0c; 有單標簽多類別文本分類和多…

任務調度器-關于中心化調度 vs 去中心化調度的核心區別

1. 定義與架構模型 維度中心化調度去中心化調度核心角色存在一個中央調度器&#xff08;如XXL-JOB的調度中心&#xff09;&#xff0c;統一管理任務分配、狀態監控和故障處理。無中心節點&#xff0c;調度邏輯分散在多個節點&#xff0c;通過共識算法&#xff08;如選舉機制&a…

[論文閱讀] 人工智能+軟件工程 | 結對編程中的知識轉移新圖景

當AI成為編程搭檔&#xff1a;結對編程中的知識轉移新圖景 論文信息 論文標題&#xff1a;From Developer Pairs to AI Copilots: A Comparative Study on Knowledge Transfer&#xff08;從開發者結對到AI副駕駛&#xff1a;知識轉移的對比研究&#xff09; 作者及機構&#…

CAD多面體密堆積3D插件

插件介紹 CAD多面體密堆積3D插件可在AutoCAD內建立三維隨機多面體密堆積模型。 插件內置物理動力學模擬算法&#xff0c;通過模擬重力、碰撞等現象&#xff0c;使多面體在虛擬環境中發生自然堆積&#xff0c;進而實現真實的堆積效果。多面體堆積模擬中存在的局部穿模問題可通…

VSCode CUDA C++進行Linux遠程開發

環境準備 確保在本地和遠程Linux服務器上安裝了以下軟件&#xff1a; Visual Studio Code&#xff08;簡稱VS Code&#xff09;Remote Development extension pack for VS CodeCUDA Toolkit&#xff0c;推薦版本為11.0或更高GCC編譯器&#xff0c;用于C代碼的編譯 此外&…

Python爬蟲(一):爬蟲偽裝

一、網站防爬機制概述 在當今互聯網環境中&#xff0c;具有一定規模或盈利性質的網站幾乎都實施了各種防爬措施。這些措施主要分為兩大類&#xff1a; 身份驗證機制&#xff1a;直接將未經授權的爬蟲阻擋在外反爬技術體系&#xff1a;通過各種技術手段增加爬蟲獲取數據的難度…

快速使用 Flutter Card 組件指南

目錄 一、引言 二、Card 的基本用法 三、主要屬性 3.1 elevation (陰影高度) 3.2 shape (形狀) 3.3 color (顏色) 3.4 margin (外邊距) 3.5 完整示例 四、結合 ListTile 組件使用 五、帶圖片的 Card 示例 六、注意事項 相關推薦 一、引言 Card 是 Flutter 提供的一個…

C語言內存管理和編譯優化實戰

參考&#xff1a; C語言內存管理“玄學”&#xff1a;從崩潰到精通的避坑指南C語言編譯優化實戰&#xff1a;從入門到進階的高效代碼優化技巧

【產品業務設計】支付業務設計規范細節記錄,含訂單記錄、支付業務記錄、支付流水記錄、退款業務記錄

【產品業務設計】支付業務設計規范細節記錄&#xff0c;含訂單記錄、支付業務記錄、支付流水記錄 前言 我為什么要寫這個篇文章 總結設計經驗生成設計模板方便后期快速搭建 一個幾張表 一共5張表&#xff1b; 分別是&#xff1a; 訂單主表&#xff1a;jjy_orderMain訂單產…

CppCon 2015 學習:Live Lock-Free or Deadlock

這段內容是介紹一場關于**“實用無鎖編程&#xff08;Practical Lock-Free Programming&#xff09;”**的講座提綱&#xff0c;重點在C中的并發編程。下面是詳細的中文理解和分析&#xff1a; 講座大綱和內容理解 主題概覽 適當的“guru崇拜”和“祈求” → 開場調侃&#…