通过apt的docker官方源安装最新的Docker CE(Community Edition) 1.更新apt
sudo apt-get update
2.使用下列指令通过HTTPS使用存储库(repository)
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
3. 安装curl
sudo apt-get -y install curl
4. 添加Docker官方GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
可能报错:
curl: (28) Operation timed out after 300415 milliseconds with 0 out of 0 bytes received
gpg: no valid OpenPGP data found.

curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to download.docker.com:443
解决:
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys D8576A8BA88D21E9
重新添加官方GPG密钥,显示 OK 即为 成功 5. 设置stable存储库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
6. 再次更新apt
sudo apt-get update
7. 安装docker-ce
sudo apt-get install -y docker-ce
如果报错:E: There were unauthenticated packages and -y was used without –allow-unauthenticated,使用命令:sudo apt-get install docker-ce 8. 列出可用版本:
apt-cache madison docker-ce

 docker-ce | 5:19.03.12~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.11~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
 docker-ce | 5:19.03.9~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages
9. 选择安装
sudo apt-get install docker-ce=5:19.03.12~3-0~ubuntu-focal
10.启动docker sudo systemctl start docker

发表评论