前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Ubuntu安装docker

Ubuntu安装docker

作者头像
是小张啊喂
发布2022-08-18 17:29:57
2.2K0
发布2022-08-18 17:29:57
举报
文章被收录于专栏:软件软件

参考官方安装地址:https://docs.docker.com/engine/install/ubuntu/

要安装 Docker Engine,您需要以下 Ubuntu 版本之一的 64 位版本:

  • Ubuntu 小鬼 21.10
  • Ubuntu 多毛 21.04
  • Ubuntu 焦点 20.04 (LTS)
  • Ubuntu 仿生 18.04 (LTS)
卸载老版本
代码语言:javascript
复制
$ sudo apt-get remove docker docker-engine docker.io containerd runc

设置新的储存器

更新apt包索引并安装包以允许apt通过 HTTPS 使用存储库

代码语言:javascript
复制
$ sudo apt-get update

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

添加官方的GPG密钥

代码语言:javascript
复制
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

使用以下命令设置稳定存储库

代码语言:javascript
复制
$ 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
安装 Docker 引擎
代码语言:javascript
复制
$ sudo apt-get update

问题: E: The repository 'https://download.docker.com/linux/ubuntu \ 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

忽略

代码语言:javascript
复制
$ 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'

编辑ubuntu源 /etc/apt/sources.list

代码语言:javascript
复制
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

$ sudo vi /etc/apt/sources.list

最后增加
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
代码语言:javascript
复制
$ sudo apt-get update

Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease Get:3 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB] Err:3 https://download.docker.com/linux/ubuntu bionic InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 Hit:4 http://archive.ubuntu.com/ubuntu focal-updates InRelease Get:5 https://download.docker.com/linux/ubuntu focal InRelease [57.7 kB] Err:5 https://download.docker.com/linux/ubuntu focal InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 Hit:6 http://archive.ubuntu.com/ubuntu focal-backports InRelease Reading package lists... Done W: GPG error: https://download.docker.com/linux/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 E: The repository 'https://download.docker.com/linux/ubuntu bionic InRelease' is not signed. 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. W: GPG error: https://download.docker.com/linux/ubuntu focal InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 7EA0A9C3F273FCD8 E: The repository 'https://download.docker.com/linux/ubuntu focal InRelease' is not signed. 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.

将公钥添加至服务器,即终端中输入

代码语言:javascript
复制
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys '7EA0A9C3F273FCD8'

Executing: /tmp/apt-key-gpghome.VIv8eLEwb3/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8
gpg: key 8D81803C0EBFCD88: 9 signatures not checked due to missing keys
gpg: key 8D81803C0EBFCD88: public key "Docker Release (CE deb) <docker@docker.com>" imported
gpg: Total number processed: 1
gpg:              imported: 1
代码语言:javascript
复制
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io

参考:https://www.jianshu.com/p/5b7c1d02f958

添加软件源

代码语言:javascript
复制
$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://mirror.aliyuncs.com"]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

这里的registry-mirrors可以替换成任意源

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-01-26,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 卸载老版本
  • 设置新的储存器
    • 安装 Docker 引擎
    相关产品与服务
    容器镜像服务
    容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
    领券
    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档