安装docker遇到的问题1: [Errno 14] curl#35 - “TCP connection reset by peer“
ubuntu安装 docker 报错****
wqbboy@mail:~$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg
[sudo] password for wqbboy:
curl: (35) Recv failure: Connection reset by peer
wqbboy@mail:~$ pwd
/home/wqbboywqbboy@mail:~$ ls
get-docker.sh offline-docspace-installation.shwqbboy@mail:~$ sudo curl -fsSL https://dow^Coad.docker.com/linux/ubuntu/gpg
执行apt-get update
wqbboy@mail:~$ sudo apt-get update
[sudo] password for wqbboy:
Hit:1 http://openresty.org/package/ubuntu noble InRelease
Hit:2 http://download.onlyoffice.com/repo/debian squeeze InRelease
Hit:3 http://repo.mysql.com/apt/ubuntu noble InRelease
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:5 https://deb.nodesource.com/node_18.x nodistro InRelease
Get:6 https://packages.adoptium.net/artifactory/deb noble InRelease [7,501 B]
Hit:7 https://ppa.launchpadcontent.net/dotnet/backports/ubuntu noble InRelease
Hit:8 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble InRelease
Get:9 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates InRelease [126 kB]
Get:10 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-backports InRelease [126 kB] Hit:21 https://packages.redis.io/deb noble InRelease
Fetched 839 kB in 4s (226 kB/s)
Reading package lists... Done
安装ca-certificates curl
wqbboy@mail:~$ sudo apt-get install ca-certificates curl
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
ca-certificates is already the newest version (20240203).
curl is already the newest version (8.5.0-2ubuntu10.6).
The following package was automatically installed and is no longer required:libllvm19
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.Set up Docker's apt repository.
增加一个目录
wqbboy@mail:~$ sudo install -m 0755 -d /etc/apt/keyrings
wqbboy@mail:~$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
curl: (35) Recv failure: Connection reset by peer
wqbboy@mail:~$ sudo curl -fsSL http://mirrors.tencentyun.com/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
curl: (6) Could not resolve host: mirrors.tencentyun.com
修改为腾讯源,报错
wqbboy@mail:~$ sudo curl -fsSL http://mirrors.tencentyun.com/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
curl: (6) Could not resolve host: mirrors.tencentyun.com
修改为阿里源,可执行成功
wqbboy@mail:~$ sudo curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
wqbboy@mail:~$ ls
get-docker.sh offline-docspace-installation.sh
wqbboy@mail:~$ cat /etc/ap
apparmor/ apparmor.d/ apport/ apt/
查看一下内容
wqbboy@mail:~$ cat /etc/apt/keyrings/docker.asc
-----BEGIN PGP PUBLIC KEY BLOCK-----mQINBFit2ioBEADhWpZ8/wvZ6hUTiXOwQHXMAlaFHcPH9hAtr4F1y2+OYdbtMuth
lqqwp028AqyY+PRfVMtSYMbjuQuu5byyKR01BbqYhuS3jtqQmljZ/bJvXqnmiVXh
38UuLa+z077PxyxQhu5BbqntTPQMfiyqEiU+BKbq2WmANUKQf+1AmZY/IruOXbnq
L4C1+gJ8vfmXQt99npCaxEjaNRVYfOS8QcixNzHUYnb6emjlANyEVlZzeqo7XKl7
UrwV5inawTSzWNvtjEjj4nJL8NsLwscpLPQUhTQ+7BbQXAwAmeHCUTQIvvWXqw0N
cmhh4HgeQscQHYgOJjjDVfoY5MucvglbIgCqfzAHW9jxmRL4qbMZj+b1XoePEtht
ku4bIQN1X5P07fNWzlgaRL5Z4POXDDZTlIQ/El58j9kp4bnWRCJW0lya+f8ocodo
vZZ+Doi+fy4D5ZGrL4XEcIQP/Lv5uFyf+kQtl/94VFYVJOleAv8W92KdgDkhTcTD
G7c0tIkVEKNUq48b3aQ64NOZQW7fVjfoKwEZdOqPE72Pa45jrZzvUFxSpdiNk2tZ
XYukHj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etc/apt/keyrings/docker.asc
执行以下代码
wqbboy@mail:~$ echo \
> "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
> (. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
> sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
更新一下
wqbboy@mail:~$ sudo apt-get update
Ign:1 https://mirrors.aliyun.com/docker-ce/linux/ubuntu (. InRelease
Err:2 https://mirrors.aliyun.com/docker-ce/linux/ubuntu (. Release 404 Not Found [IP: 122.228.67.173 443]
Hit:3 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:4 http://repo.mysql.com/apt/ubuntu noble InRelease
Hit:5 http://download.onlyoffice.com/repo/debian squeeze InRelease
Hit:6 https://deb.nodesource.com/node_18.x nodistro InRelease
Hit:7 https://ppa.launchpadcontent.net/dotnet/backports/ubuntu noble InRelease
Get:8 https://packages.adoptium.net/artifactory/deb noble InRelease [7,501 B]
Hit:9 http://openresty.org/package/ubuntu noble InRelease
Hit:10 https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable InRelease
Hit:11 https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/apt stable InRelease
Hit:12 https://packages.redis.io/deb noble InRelease
Hit:13 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble InRelease
Hit:14 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates InRelease
Hit:15 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-backports InRelease
Reading package lists... Done
E: The repository 'https://mirrors.aliyun.com/docker-ce/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.
安装docker-ce
wqbboy@mail:~$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
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 sourcePackage docker-ce-cli 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 sourceE: Package 'docker-ce' has no installation candidate
E: Package 'docker-ce-cli' has no installation candidate
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'
E: Unable to locate package docker-buildx-plugin
E: Unable to locate package docker-compose-plugin
wqbboy@mail:~$ 首先,确保你的包索引是最新的。打开终端并运行以下命令:```c
sudo apt update
安装必要的依赖
安装Docker之前,你需要确保所有必要的依赖都已安装:
wqbboy@mail:~$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
apt-transport-https is already the newest version (2.8.3).
ca-certificates is already the newest version (20240203).
curl is already the newest version (8.5.0-2ubuntu10.6).
software-properties-common is already the newest version (0.99.49.3).
The following package was automatically installed and is no longer required:libllvm19
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
添加Docker的官方GPG密钥
为了验证下载的Docker包,你需要添加Docker的官方GPG密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -wqbboy@mail:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
检查仓库地址格式,查找正确的密钥ID,然后使用以下命令添加:
sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
wqbboy@mail:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Repository: 'deb [arch=amd64] https://download.docker.com/linux/ubuntu noble stable'
Description:
Archive for codename: noble components: stable
More info: https://download.docker.com/linux/ubuntu
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/archive_uri-https_download_docker_com_linux_ubuntu-noble.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-https_download_docker_com_linux_ubuntu-noble.list
Ign:1 https://download.docker.com/linux/ubuntu noble InRelease
Get:2 https://mirrors.aliyun.com/docker-ce/linux/ubuntu noble InRelease [48.8 kB]
Ign:3 https://mirrors.aliyun.com/docker-ce/linux/ubuntu (. InRelease
Hit:4 http://openresty.org/package/ubuntu noble InRelease
Err:5 https://mirrors.aliyun.com/docker-ce/linux/ubuntu (. Release 404 Not Found [IP: 49.79.229.69 443]
Get:6 https://mirrors.aliyun.com/docker-ce/linux/ubuntu noble/stable amd64 Packages [30.5 kB]
Hit:7 http://repo.mysql.com/apt/ubuntu noble InRelease
Hit:8 http://download.onlyoffice.com/repo/debian squeeze InRelease
Hit:9 https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable InRelease
Hit:10 https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/apt stable InRelease
Get:11 https://packages.adoptium.net/artifactory/deb noble InRelease [7,501 B]
Hit:12 https://ppa.launchpadcontent.net/dotnet/backports/ubuntu noble InRelease
Ign:1 https://download.docker.com/linux/ubuntu noble InRelease
Hit:13 https://deb.nodesource.com/node_18.x nodistro InRelease
Get:1 https://download.docker.com/linux/ubuntu noble InRelease [48.8 kB]
Hit:14 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:15 https://packages.redis.io/deb noble InRelease
Get:16 https://download.docker.com/linux/ubuntu noble/stable amd64 Packages [30.5 kB]
Hit:17 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble InRelease
Ign:18 http://cn.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:19 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-backports InRelease
Hit:18 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates InRelease
Reading package lists... Done
W: https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/noble/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
E: The repository 'https://mirrors.aliyun.com/docker-ce/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.
W: https://download.docker.com/linux/ubuntu/dists/noble/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
再次更新包索引
添加仓库后,再次更新你的包索引:
sudo apt update
wqbboy@mail:~$ sudo apt update
Hit:1 http://openresty.org/package/ubuntu noble InRelease
Hit:2 https://mirrors.aliyun.com/docker-ce/linux/ubuntu noble InRelease
Ign:3 https://download.docker.com/linux/ubuntu noble InRelease
Ign:4 https://mirrors.aliyun.com/docker-ce/linux/ubuntu (. InRelease
Hit:5 http://repo.mysql.com/apt/ubuntu noble InRelease
Err:6 https://mirrors.aliyun.com/docker-ce/linux/ubuntu (. Release 404 Not Found [IP: 150.139.244.198 443]
Hit:7 http://download.onlyoffice.com/repo/debian squeeze InRelease
Hit:8 http://security.ubuntu.com/ubuntu noble-security InRelease
Get:9 https://packages.adoptium.net/artifactory/deb noble InRelease [7,501 B]
Hit:10 https://deb.nodesource.com/node_18.x nodistro InRelease
Hit:12 https://ppa.launchpadcontent.net/dotnet/backports/ubuntu noble InRelease
Hit:13 https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable InRelease
Hit:14 https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.x/apt stable InRelease
Hit:11 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble InRelease
Hit:15 https://packages.redis.io/deb noble InRelease
Hit:3 https://download.docker.com/linux/ubuntu noble InRelease
Hit:16 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-updates InRelease
Hit:17 http://mirrors.tuna.tsinghua.edu.cn/ubuntu noble-backports InRelease
Reading package lists... Done
W: https://mirrors.aliyun.com/docker-ce/linux/ubuntu/dists/noble/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
E: The repository 'https://mirrors.aliyun.com/docker-ce/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.
W: https://download.docker.com/linux/ubuntu/dists/noble/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
安装Docker CE
现在,你应该能够安装Docker CE了:
sudo apt install docker-ce docker-ce-cli containerd.io
检查Docker安装
安装完成后,你可以通过运行以下命令来检查Docker是否正确安装:
docker --version
sudo docker run hello-world
wqbboy@mail:~$ docker --version
Docker version 28.4.0, build d8eb465
wqbboy@mail:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally