从 repo 在 Ubuntu 中安装 Docker。找不到回购

Installing Docker in Ubuntu, from repo. Can't find a repo

我正在尝试关注 official documentation。 但是,当我 运行 命令 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'

此外,当 运行ning apt-cache madison docker-ce 时,终端中什么也没有显示...

使用curl https://get.docker.com/ | bash -这是一个适用于大多数情况的自动化脚本

1.更新 APT:

sudo apt-get update

2。首先安装这些软件包:

sudo apt-get install \
     ca-certificates \
     curl \
     gnupg \
     lsb-release

3。添加 GPG 密钥:

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

4.然后添加 Docker 存储库:

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

5.再次更新:

sudo apt-get update

6.安装 docker-ce、cli 和 containerd.io:

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

必须有效 - 确保以 root 身份或使用 sudo 执行所有命令。

您也可以使用他们的脚本来自动化一切:

 curl -fsSL https://get.docker.com -o get-docker.sh
 sudo ./get-docker.sh