mac m3 從 docker desktop 到 podman desktop

podman desktop 安裝

brew install podman
brew install --cask podman-desktop
brew tap slp/krunkit
brew install krunkit

podman desktop 配置

podman machine init
podman machine start

如果報(bào)錯(cuò): 沒有 krunkit, 參考上文安裝 krunkit

sudo podman-mac-helper install

在 podman desktop 中調(diào)整虛擬機(jī)內(nèi)存: (Settings -> Resources -> Podman: edit icon, 修改后 Update);
也可在 init 時(shí)指定: podman machine init --cpus 4 --memory=8192

https://medium.com/rahasak/switching-from-docker-desktop-to-podman-on-macos-m1-m2-arm64-cpu-7752c02453ec

https://desktop.podman.org.cn/docs/migrating-from-docker/using-podman-mac-helper

遷移鏡像(不成功)

docker save -o open-webui.main.tar ghcr.io/open-webui/open-webui:main
podman load -i open-webui.main.tar

會(huì)導(dǎo)致 podman 虛擬機(jī)卡死無(wú)響應(yīng), 停也停不了.
問題太大, 算了, 直接重新拉鏡像吧.

卸載 docker desktop

sudo /Applications/Docker.app/Contents/MacOS/uninstall

Uninstalling Docker Desktop...
Error: unlinkat /Users/USER_HOME/Library/Containers/com.docker.docker/.com.apple.containermanagerd.metadata.plist: > operation not permitted

解決: (System Settings > Privacy & Security > Full Disk Access), 給使用的 terminal 授予權(quán)限

rm -rf ~/Library/Group\ Containers/group.com.docker
rm -rf ~/.docker

應(yīng)用程序中, 把 Docker Desktop 拖到回收站

參考: https://docs.docker.com/desktop/uninstall/

使用 kind 安裝本地 k8s 集群

  1. 安裝 golang 版本管理器 g
cat << 'EOF' >> ~/.zshrc
# 可選。檢查g別名是否被占用
if [[ -n $(alias g 2>/dev/null) ]]; then
    unalias g
fi
EOF

curl -sSL https://raw.githubusercontent.com/voidint/g/master/install.sh | bash

  1. 安裝 golang
    g ls-remote stable
    g install 1.24.6
    go vesion

  2. 安裝 kind
    go install sigs.k8s.io/kind@v0.30.0

  3. 創(chuàng)建 k8s 集群
    kind create cluster

參考: https://kind.sigs.k8s.io/

有坑嗎?

不出意外的, 有!

podman 容器讀取宿主機(jī)留下的docker掛載目錄時(shí), 存在權(quán)限不足問題, 例如 postgresql 留下的數(shù)據(jù)目錄.
如何解決?

  1. 宿主機(jī)上, 為其他用戶在目標(biāo)目錄上授予讀和執(zhí)行權(quán)限. chmod -R +rx postgre-data (這是宿主目錄)
  2. 進(jìn)入podman虛擬機(jī)中, 修改目錄權(quán)限
# 在宿主機(jī)上, 登錄podman虛擬機(jī)
podman machine ssh
# 查看掛載點(diǎn), 并轉(zhuǎn)到目錄下
mount
df -h
cd /Users/<hostUserName>/<宿主機(jī)掛載目標(biāo)路徑>
# 修改屬主
sudo chown -R core:games postgre-data

一般這種就是宿主機(jī)掛載點(diǎn)


image.png
  1. 使用一個(gè)臨時(shí)容器復(fù)制文件到新建卷上
# 新建數(shù)據(jù)卷
podman volume create litellm_pg_data
# 復(fù)制數(shù)據(jù)到新建卷
podman run --rm -it \
  -v "$(pwd)/postgre-data":/host_data \
  -v litellm_pg_data:/container_data \
  redis:8.2.1 \
  bash
cp -rp /host_data/. /container_data/
  1. 使用新建卷啟動(dòng)容器
docker run -d \
--name litellm-postgre \
-v litellm_pg_data:/var/lib/postgresql/data \
-p 5432:5432 \
-e POSTGRES_PASSWORD=<你的pg密碼> \
-e LANG=C.UTF-8 \
postgres:latest

方案的不足: 數(shù)據(jù)的變更, 將保留在 podman 虛擬機(jī)中, 無(wú)法再在宿主目錄中保留.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • """1.個(gè)性化消息: 將用戶的姓名存到一個(gè)變量中,并向該用戶顯示一條消息。顯示的消息應(yīng)非常簡(jiǎn)單,如“Hello ...
    她即我命閱讀 4,846評(píng)論 0 6
  • 為了讓我有一個(gè)更快速、更精彩、更輝煌的成長(zhǎng),我將開始這段刻骨銘心的自我蛻變之旅!從今天開始,我將每天堅(jiān)持閱...
    李薇帆閱讀 2,226評(píng)論 1 4
  • 似乎最近一直都在路上,每次出來(lái)走的時(shí)候感受都會(huì)很不一樣。 1、感恩一直遇到好心人,很幸運(yùn)。在路上總是...
    時(shí)間里的花Lily閱讀 1,703評(píng)論 1 3
  • 1、expected an indented block 冒號(hào)后面是要寫上一定的內(nèi)容的(新手容易遺忘這一點(diǎn)); 縮...
    庵下桃花仙閱讀 1,057評(píng)論 1 2
  • 一、工具箱(多種工具共用一個(gè)快捷鍵的可同時(shí)按【Shift】加此快捷鍵選取)矩形、橢圓選框工具 【M】移動(dòng)工具 【V...
    墨雅丫閱讀 1,431評(píng)論 0 0

友情鏈接更多精彩內(nèi)容