无法在 WSL 中找到容器运行时“podman”

Aspire 要求容器运行时在系统 PATH 中可用。 本文介绍如何解决在适用于 (WSL) 环境的 Windows 子系统Podman中找不到的问题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 安装在单独的 WSL 分发版中,而不是应用程序 Aspire 正在运行的位置。
  • 你使用的是 shell 别名,而不是在 PATH 中使用实际 Podman 可执行文件。
  • Podman可执行文件在搜索的系统 PATH Aspire 中不可用。

Aspire 通过在系统 PATH 中搜索可执行文件来解析容器运行时。 在此过程中,无法识别 Shell 别名(如在中 ~/.bash_aliases定义的别名)。

解决方案

选择以下解决方案之一:

在当前 WSL 分发版中安装Podman

直接在运行应用程序的 Podman WSL 分发版中安装Aspire:

# 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 应用程序之前,所有命令都应成功。

另请参阅