Ubuntu 22-04 LTS 安装docker

可以参考以下官方安装地址:Install Docker Engine on Ubuntu | Docker Documentation

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

  • Ubuntu 小鬼 21.10
  • Ubuntu 多毛 21.04
  • Ubuntu 焦点 20.04 (LTS)
  • Ubuntu 仿生 18.04 (LTS)

卸载老版本

$ sudo apt-get remove docker docker-engine docker.io containerd runc

设置新的储存器

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

$ sudo apt-get update

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

添加官方的GPG密钥

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

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

$ 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 引擎

$ sudo apt-get update

问题: E: The repository 'Index of 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

忽略即可

$ 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'

两种方法:

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

$ 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

2、还是sources.list,替换为

清华镜像https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
$ sudo apt-get update

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

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

$ 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

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

添加镜像加速(阿里云的,可以自行去官网注册,是免费的呦)

$ 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可以替换成任意源

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无言5525

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值