背景简介
在 Linux Mint 中安装 Docker 环境
环境配置
- 系统:Linux my-dev 6.8.0-38-generic #38-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:25:01 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
详细步骤
【官方参考文档】
一、添加 apt 仓库
第一步: apt-get update
~$ sudo apt-get update
[sudo] myserver 的密码:
命中:1 http://mirrors.aliyun.com/ubuntu noble InRelease
命中:2 http://mirrors.aliyun.com/ubuntu noble-updates InRelease
命中:3 http://mirrors.aliyun.com/ubuntu noble-backports InRelease
忽略:4 https://mirrors.nju.edu.cn/linuxmint wilma InRelease
命中:5 https://mirrors.nju.edu.cn/linuxmint wilma Release
命中:6 http://security.ubuntu.com/ubuntu noble-security InRelease
正在读取软件包列表... 完成
第二步:apt-get install ca-certificates curl
~$ sudo apt-get install ca-certificates curl
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
ca-certificates 已经是最新版 (20240203)。
将会同时安装下列软件:
libcurl3t64-gnutls libcurl4t64
下列软件包将被升级:
curl libcurl3t64-gnutls libcurl4t64
升级了 3 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 325 个软件包未被升级。
需要下载 901 kB 的归档。
解压缩后会消耗 3,072 B 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://mirrors.aliyun.com/ubuntu noble-updates/main amd64 libcurl3t64-gnutls amd64 8.5.0-2ubuntu10.6 [333 kB]
获取:2 http://mirrors.aliyun.com/ubuntu noble-updates/main amd64 curl amd64 8.5.0-2ubuntu10.6 [226 kB]
获取:3 http://mirrors.aliyun.com/ubuntu noble-updates/main amd64 libcurl4t64 amd64 8.5.0-2ubuntu10.6 [341 kB]
已下载 901 kB,耗时 0秒 (5,763 kB/s)
(正在读取数据库 ... 系统当前共安装有 461131 个文件和目录。)
准备解压 .../libcurl3t64-gnutls_8.5.0-2ubuntu10.6_amd64.deb ...
正在解压 libcurl3t64-gnutls:amd64 (8.5.0-2ubuntu10.6) 并覆盖 (8.5.0-2ubuntu10.1) ...
正在设置 libcurl3t64-gnutls:amd64 (8.5.0-2ubuntu10.6) ...
(正在读取数据库 ... 系统当前共安装有 461131 个文件和目录。)
准备解压 .../curl_8.5.0-2ubuntu10.6_amd64.deb ...
正在解压 curl (8.5.0-2ubuntu10.6) 并覆盖 (8.5.0-2ubuntu10.1) ...
准备解压 .../libcurl4t64_8.5.0-2ubuntu10.6_amd64.deb ...
正在解压 libcurl4t64:amd64 (8.5.0-2ubuntu10.6) 并覆盖 (8.5.0-2ubuntu10.1) ...
正在设置 libcurl4t64:amd64 (8.5.0-2ubuntu10.6) ...
正在设置 curl (8.5.0-2ubuntu10.6) ...
正在处理用于 man-db (2.12.0-4build2) 的触发器 ...
正在处理用于 libc-bin (2.39-0ubuntu8.2) 的触发器 ...
第三步: install -m 0755 -d /etc/apt/keyrings
~$ sudo install -m 0755 -d /etc/apt/keyrings
第四步:curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
~$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
curl: (35) Recv failure: 连接被对方重置
~$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
如果连接被重置,可以通过多次重试进行配置。
第五步:chmod a+r /etc/apt/keyrings/docker.asc
~$ sudo chmod a+r /etc/apt/keyrings/docker.asc
第六步:添加 docker.lsit
~$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
第七步: apt-get update
,如遇到404 Not Found
报错,则需要修改 docker.list
信息,如无报错则第一阶段配置完成。
~$ sudo apt-get update
忽略:1 https://mirrors.nju.edu.cn/linuxmint wilma InRelease
命中:2 https://mirrors.nju.edu.cn/linuxmint wilma Release
命中:3 http://mirrors.aliyun.com/ubuntu noble InRelease
命中:4 http://mirrors.aliyun.com/ubuntu noble-updates InRelease
命中:5 http://mirrors.aliyun.com/ubuntu noble-backports InRelease
忽略:7 https://download.docker.com/linux/ubuntu wilma InRelease
命中:8 http://security.ubuntu.com/ubuntu noble-security InRelease
忽略:7 https://download.docker.com/linux/ubuntu wilma InRelease
错误:9 https://download.docker.com/linux/ubuntu wilma Release
404 Not Found [IP: 3.169.137.4 443]
正在读取软件包列表... 完成
E: 仓库 “https://download.docker.com/linux/ubuntu wilma Release” 没有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
查看 /etc/apt/sources.list.d/docker.list
文件
~$ cat /etc/apt/sources.list.d/docker.list
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu wilma stable
由于 wilma 相关内容找不到,因此我们需要更新为 Linux Mint 对应的 Ubuntu 版本。
~$ cat /etc/os-release
NAME="Linux Mint"
VERSION="22 (Wilma)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 22"
VERSION_ID="22"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=wilma
UBUNTU_CODENAME=noble
主要对应关系
Linux Mint 22.x 对应 Ubuntu 24.04 LTS (Noble Numbat)
Linux Mint 21.x 对应 Ubuntu 22.04 LTS (Jammy Jellyfish)
Linux Mint 20.x 对应 Ubuntu 20.04 LTS (Focal Fossa)
Linux Mint 19.x 对应 Ubuntu 18.04 LTS (Bionic Beaver)
Linux Mint 18.x 对应 Ubuntu 16.04 LTS (Xenial Xerus)
Linux Mint 17.x 对应 Ubuntu 14.04 LTS (Trusty Tahr)
这里我选择 noble
进行更新,更新后 docker.list
文件内容为
deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu noble stable
配置完成后再次更新 apt
$ sudo apt-get update
忽略:1 https://mirrors.nju.edu.cn/linuxmint wilma InRelease
命中:2 https://mirrors.nju.edu.cn/linuxmint wilma Release
命中:4 http://mirrors.aliyun.com/ubuntu noble InRelease
命中:5 http://security.ubuntu.com/ubuntu noble-security InRelease
命中:6 http://mirrors.aliyun.com/ubuntu noble-updates InRelease
命中:7 http://mirrors.aliyun.com/ubuntu noble-backports InRelease
获取:8 https://download.docker.com/linux/ubuntu noble InRelease [48.8 kB]
获取:9 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages [17.2 kB]
已下载 66.1 kB,耗时 7秒 (9,434 B/s)
正在读取软件包列表... 完成
二、安装 Docker
第一步:安装 Docker 相关组件:docker-ce
、docker-ce-cli
、containerd.io
、docker-buildx-plugin
、docker-compose-plugin
~$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
将会同时安装下列软件:
docker-ce-rootless-extras git git-man liberror-perl libslirp0 pigz slirp4netns
建议安装:
aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb
git-cvs git-mediawiki git-svn
下列【新】软件包将被安装:
containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin git
git-man liberror-perl libslirp0 pigz slirp4netns
升级了 0 个软件包,新安装了 12 个软件包,要卸载 0 个软件包,有 325 个软件包未被升级。
需要下载 124 MB/129 MB 的归档。
解压缩后会消耗 470 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 https://download.docker.com/linux/ubuntu noble/stable amd64 containerd.io amd64 1.7.24-1 [29.5 MB]
获取:2 https://download.docker.com/linux/ubuntu noble/stable amd64 docker-buildx-plugin amd64 0.19.3-1~ubuntu.24.04~noble [30.7 MB]
******
备选:如果无法安装或者安装很慢,也可以通过下载
deb
安装包安装。下载路径: https://download.docker.com/linux/ubuntu/dists/ ,选择自己对应的版本目录
例如我的是: https://download.docker.com/linux/ubuntu/dists/noble/pool/stable/amd64/ 选择如下安装包下载
containerd.io_<version>_<arch>.deb docker-ce_<version>_<arch>.deb docker-ce-cli_<version>_<arch>.deb docker-buildx-plugin_<version>_<arch>.deb docker-compose-plugin_<version>_<arch>.deb
安装
~$ sudo dpkg -i ./containerd.io_<version>_<arch>.deb \ ./docker-ce_<version>_<arch>.deb \ ./docker-ce-cli_<version>_<arch>.deb \ ./docker-buildx-plugin_<version>_<arch>.deb \ ./docker-compose-plugin_<version>_<arch>.deb
安装完成后,可查看 Docker 版本
~$ sudo docker version
Client: Docker Engine - Community
Version: 27.4.1
API version: 1.47
Go version: go1.22.10
Git commit: b9d17ea
Built: Tue Dec 17 15:45:46 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 27.4.1
API version: 1.47 (minimum version 1.24)
Go version: go1.22.10
Git commit: c710b88
Built: Tue Dec 17 15:45:46 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.24
GitCommit: 88bf19b2105c8b17560993bee28a01ddc2f97182
runc:
Version: 1.2.2
GitCommit: v1.2.2-0-g7cb3632
docker-init:
Version: 0.19.0
GitCommit: de40ad0
以上便是本文的全部内容,感谢您的阅读。