共用方式為


WSL 中找不到容器運行時間 'podman'

Aspire 需要容器執行階段在系統 PATH 中可用。 本文說明如何在 Windows 子系統 Podman (WSL) 環境中找不到時Linux解決問題。

癥狀

啟動 Aspire 應用程式時,您會看到類似下列的錯誤訊息:

Container runtime 'podman' could not be found. The error from the container runtime check was: exec: "podman": executable file not found in $PATH

即使執行 podman images 或其他 Podman 命令在 WSL 終端機中順利運作,仍會發生此情況。

原因

當下列情況發生於 WSL 環境中發生此問題:

  • Podman 安裝在與應用程式執行位置 Aspire 不同的 WSL 散發套件中。
  • 您使用的是殼層別名,而不是在PATH中擁有實際的 Podman 可執行檔。
  • 可執行檔 Podman 無法在搜尋的系統PATH Aspire 中使用。

Aspire 透過在系統 PATH 中搜尋可執行檔來解析容器執行階段。 殼層別名(例如在 中 ~/.bash_aliases定義的別名)在此程式期間無法辨識。

解決方法

選擇下列其中一個解決方案:

在目前的 WSL 散發套件中安裝Podman

Podman直接安裝在您執行Aspire應用程式的 WSL 散發套件中:

# For Ubuntu/Debian-based distributions
sudo apt update
sudo apt install -y podman

如需其他散發套件,請參閱 在 Podman 上安裝 Linux

如果您已在 Podman 其他地方安裝,請建立符號連結:

# Find where Podman is installed
which podman-remote-static-linux_amd64

# Create a symbolic link in a directory that's in your PATH
sudo ln -s /path/to/podman-remote-static-linux_amd64 /usr/local/bin/podman

將目錄新增 Podman 至PATH

將包含可執行檔案的 Podman 目錄新增至您的PATH:

# Add to your shell profile
echo 'export PATH="/path/to/podman/directory:$PATH"' >> ~/.bashrc
source ~/.bashrc

確認解決方案

Podman確認已正確設定:

# Check that Podman is in your PATH
which podman

# Verify Podman is working
podman --version

# Test that Podman can list containers
podman ps

在執行 Aspire 應用程式之前,所有命令都應該成功。

另請參閱