从存储库在 Ubuntu 中安装 Docker。找不到回购

An *_*ea. 3 docker ubuntu-20.04

我正在尝试遵循官方文档。但是,当我运行命令时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'
Run Code Online (Sandbox Code Playgroud)

另外,运行时apt-cache madison docker-ce,终端中没有显示任何内容......

Krz*_*ski 9

1.更新APT:

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

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

sudo apt-get install \
     ca-certificates \
     curl \
     gnupg \
     lsb-release
Run Code Online (Sandbox Code Playgroud)

3.添加GPG密钥:

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

5.再次更新:

sudo apt-get update
Run Code Online (Sandbox Code Playgroud)

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

sudo apt-get install docker-ce docker-ce-cli containerd.io
Run Code Online (Sandbox Code Playgroud)

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

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

 curl -fsSL https://get.docker.com -o get-docker.sh
 sudo ./get-docker.sh
Run Code Online (Sandbox Code Playgroud)


小智 5

使用curl https://get.docker.com/ | bash -这是一个在大多数情况下都可以工作的自动化脚本