无法在 Windows 10 中运行 WSL2 的 Ubuntu 20.04 中安装 podman

无法在 Windows 10 中运行 WSL2 的 Ubuntu 20.04 中安装 podman

例如,我无法按照官方 RedHat 说明或任何其他说明安装 podman。

我总是遇到同样的情况

diegosasw@LAP-DMARTIN:~$ sudo apt-get -qq -y install podman
E: Unable to correct problems, you have held broken packages.
diegosasw@LAP-DMARTIN:~$ sudo apt-get -y install podman
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 podman : Depends: containers-common (>= 1.2.0~3) but it is not going to be installed
          Recommends: crun but it is not going to be installed
          Recommends: slirp4netns but it is not going to be installed
          Recommends: uidmap but it is not going to be installed
          Recommends: varlink but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

我尝试过升级sudo apt-get upgrade,所有东西都是最新的。问题还是一样。如果有问题的话,我可以看到安装了 containers-common 1.2.0~2,但从未安装过 1.2.0.~3(假设这是软件包损坏的原因)。

有人知道原因吗?这是一个全新的 Ubuntu 20.04 发行版,以下是首次运行时遵循的步骤https://oldgitops.medium.com/setting-up-podman-on-wsl2-in-windows-10-be2991c2d443

. /etc/os-release

sudo sh -c "echo 'deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"

curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key | sudo apt-key add -

sudo apt-get update -qq

sudo apt-get -qq -y install podman

我有以下内容:

diegosasw@LAP-DMARTIN:~$ ls /etc/apt/sources.list.d
devel:kubic:libcontainers:stable.list

答案1

最近被提及的一个老问题,但对于任何想知道的人来说,截至本文发表时,podman.io目前适用于 WSL2 上的 Ubuntu。

有两个选项:

  • 首先,如果你将 WSL2 Ubuntu 安装更新至 21.10,我的答案在这里,您可以简单地:

    sudo apt-get -y update
    sudo apt-get -y install podman
    
  • 如果您更喜欢在 WSL2 Ubuntu 20.04 (LTS) 上安装,podman.io 上的常规说明也适用,只需进行一些细微调整。

    1. 第一的(但 podman 文档中未提及),在尝试安装 podman repo 密钥之前,请确保您当前的发行版是最新的。否则,您可能会遇到过期的证书链:

      sudo apt update && sudo apt upgrade -y
      
    2. 运行命令podman 文档。目前情况如下:

      . /etc/os-release
      echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
      curl -L "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | sudo apt-key add -
      sudo apt-get update
      sudo apt-get -y upgrade
      sudo apt-get -y install podman
      

      但是,请参阅文档以获取最新信息。

    3. podman 文档中也没有提到,但您可能需要添加:

      sudo apt install buildah
      

      该包包含为 21.10podman包的依赖项,但您需要在 20.04 上手动添加它。

相关内容