在Ubuntu 20.04 LTS(Vmware)上安装Docker失败

29
我正在使用Ubuntu VM on VMware按照https://docs.docker.com/engine/install/ubuntu/上的指南安装docker。但是,在运行添加仓库到Ubuntu的命令时遇到了问题。
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

我遇到了以下错误:
Get:1 http://us.archive.ubuntu.com/ubuntu focal InRelease [265 kB]                                                                           
Ign:2 http://dl.google.com/linux/chrome/deb stable InRelease                                                                                 
Hit:3 http://dl.google.com/linux/chrome/deb stable Release                                                                                   
Hit:5 http://security.ubuntu.com/ubuntu focal-security InRelease                                                                             
Ign:6 https://download.docker.com/linux/ubuntu focal InRelease                                             
Err:7 https://download.docker.com/linux/ubuntu focal Release
  404  Not Found [IP: 13.225.7.126 443]
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [89.1 kB]
Hit:9 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
E: The repository 'https://download.docker.com/linux/ubuntu focal Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

在运行命令时

sudo apt-get install docker-ce docker-ce-cli containerd.io

我遇到了错误。
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package docker-ce is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'docker-ce' has no installation candidate
E: Unable to locate package docker-ce-cli
E: Unable to locate package containerd.io
E: Couldn't find any package by glob 'containerd.io'
E: Couldn't find any package by regex 'containerd.io'

为什么会出现这种情况?我对docker不是很熟悉。是否有解决办法,或者应该使用源代码安装docker?谢谢。


1
Docker的内部仓库目前还不支持20.04。 - Matt Schuchard
@MattSchuchard 这可以通过下面选择的答案来完成。 - Menuka Ishan
我忘记将稳定通道添加到存储库中了,请添加 echo \ deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 然后尝试安装,这样就可以正常工作了。 - Abrar Ansari
8个回答

73

目前,您可以使用:

sudo apt-get install -y docker.io

然后检查:

docker -v

5
-y, --yes, --assume-yes:自动确认提示信息;假定所有提示信息的答案都是"Yes",并以非交互方式运行。 - Wared
我不知道那个。谢谢。 - Menuka Ishan
那对我有用!愚蠢的Ubuntu Snaps让我重新安装,但是你的命令仍然有效。 - Alex. S.
4
即使在2022年,这仍然有效。官方代码库存在一些证书问题。 - Vishnoo Rath
请同时检查 sudo docker run hello-world - undefined

14
根据我在电脑上测试并遵循文档,这些说明将成功地在VMware Ubuntu focal上安装docker。
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl  gnupg
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

输入图片说明


1
实际上,“apt-get update”这个命令大家都错过了,直接去安装docker.io。所以上面的建议是正确的。再次执行“apt-get update”命令,然后尝试安装。 - Biddut Mitra

10

Docker尚未发布focal fossa(20.04)的存储库。正如@Wared所说,运行

sudo apt install -y docker.io

将从Ubuntu存储库获取Docker。

我能够在这个Docker安装上成功使用我之前在18.04中使用的所有Docker镜像。


这是唯一对我有效的方法。我正在使用一个新的DigitalOcean droplet,其中 uname -a Linux dev-2 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux - Bryan

5

我知道这个问题是关于Ubuntu 20的。但是如果你像我一样尝试在Linux Mint 20上安装它,问题看起来是一样的,但答案却不同。

安装指南告诉你要像这样添加PPA:

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

然而,问题在于$(lsb_release -cs)部分,因为它将发行版名称作为参数传递给仓库命令。在Ubuntu 20上,该命令输出focal,一切都很顺利,但在Linux Mint上,该命令则输出ulyana,因为docker没有这个版本。
如果你想在Mint上安装它,只需将该命令替换为focal字符串,以便获取ubuntu focal版本:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
focal \
stable"

2

4
他们更新了页面,现在20.04出现在列表中,但存储库仍然无法使用。 - Jens
忘掉我说的话,我的问题是我试图在Linux Mint上安装它。 - Jens

2
Ubuntu 20.04 LTS的Docker仓库还没有准备好(我不明白为什么他们不集中精力准备它,而是发布了非LTS版本如19.10!)。但在Ubuntu Universe仓库中已经有一个较新的版本,所以目前可以先使用这个版本。当Docker的20.04仓库准备就绪时,只需按照以下说明操作:https://docs.docker.com/engine/install/ubuntu/,并包括“卸载旧版本”部分。这样,您就可以在Ubuntu 20.04上开始使用Docker了。

如果您提供从“Ubuntu Universe”安装的说明,将会很有帮助。 - Iulian Onofrei
为什么笑?这是推荐的方式。 对于那样的应用程序,您永远不会使用过时的分发包。 - Markus
我之所以这样说是因为我不知道“Ubuntu Universe”是什么,也不知道如何使用它,认为可能不只有我会从一些额外的信息中受益。 - Iulian Onofrei

1

上述错误是由于命令复制不干净造成的。请注意这一点,再次复制命令以解决错误。它帮助我纠正了相同的错误。


似乎我也遇到了这个问题。将命令复制到文本文件中,从中复制并执行,一切都顺利进行。 - Pavindu

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接