Ubuntu 22.04 在线安装docker报错E: Package ‘docker-ce‘ has no installation candidate
风行無痕 2024-07-17 13:07:02 阅读 90
一、报错描述
在ubuntu 22.01上执行在线安装docker命令时出现E: Package 'docker-ce' has no installation candidate错误。
<code>sudo apt install docker-ce docker-ce-cli containerd.io
下面是详细报错信息
root@ubuntu:# sudo apt install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'moby-containerd' instead of 'containerd.io'
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
However the following packages replace it:
moby-engine:armhf moby-cli:armhf moby-cli:arm64 moby-engine:arm64 moby-cli moby-engine
Package 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 source
However the following packages replace it:
moby-cli:armhf moby-cli:arm64 moby-cli
E: Package 'docker-ce' has no installation candidate
E: Package 'docker-ce-cli' has no installation candidate
E: Unable to locate package docker-compose-plugin
root@ubuntu:#
二、问题分析
这种报错信息,很明显是说明apt的源设置的不对。
三、解决步骤
安装阿里云证书,并配置阿里云的docker源
# 安装阿里云gpg证书
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add
# 在指定目录下新建docker.list文件,添加阿里云镜像源
cd /etc/apt/sources.list.d
sudo touch docker.list
sudo chmod 666 docker.list
sudo echo "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" > docker.list
修改完成之后需要执行如下命令才会生效
# 更新软件源
sudo apt-get update && sudo apt-get upgrade
重新执行命令安装
# 安装最新Docker
sudo apt install docker-ce docker-ce-cli containerd.io
下面是安装过程
root@ubuntu:/#
root@ubuntu:/# sudo apt install docker-ce docker-ce-cli containerd.io
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
dotnet-host dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-runtime-deps-8.0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
docker-buildx-plugin docker-ce-rootless-extras docker-compose-plugin libslirp0 pigz slirp4netns
Suggested packages:
aufs-tools cgroupfs-mount | cgroup-lite
The following NEW packages will be installed:
containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin libslirp0 pigz slirp4netns
0 upgraded, 9 newly installed, 0 to remove and 4 not upgraded.
Need to get 121 MB/121 MB of archives.
After this operation, 434 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 containerd.io amd64 1.6.33-1 [30.0 MB]
Get:2 https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-buildx-plugin amd64 0.14.1-1~ubuntu.22.04~jammy [29.6 MB]
Get:3 https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-ce-cli amd64 5:26.1.4-1~ubuntu.22.04~jammy [14.6 MB]
Get:4 https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-ce amd64 5:26.1.4-1~ubuntu.22.04~jammy [25.3 MB]
Get:5 https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-ce-rootless-extras amd64 5:26.1.4-1~ubuntu.22.04~jammy [9,319 kB]
Get:6 https://mirrors.aliyun.com/docker-ce/linux/ubuntu jammy/stable amd64 docker-compose-plugin amd64 2.27.1-1~ubuntu.22.04~jammy [12.5 MB]
Fetched 115 MB in 6min 36s (289 kB/s)
Selecting previously unselected package pigz.
(Reading database ... 117428 files and directories currently installed.)
Preparing to unpack .../0-pigz_2.6-1_amd64.deb ...
Unpacking pigz (2.6-1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../1-containerd.io_1.6.33-1_amd64.deb ...
Unpacking containerd.io (1.6.33-1) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../2-docker-buildx-plugin_0.14.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-buildx-plugin (0.14.1-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../3-docker-ce-cli_5%3a26.1.4-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-cli (5:26.1.4-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../4-docker-ce_5%3a26.1.4-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce (5:26.1.4-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../5-docker-ce-rootless-extras_5%3a26.1.4-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:26.1.4-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../6-docker-compose-plugin_2.27.1-1~ubuntu.22.04~jammy_amd64.deb ...
Unpacking docker-compose-plugin (2.27.1-1~ubuntu.22.04~jammy) ...
Selecting previously unselected package libslirp0:amd64.
Preparing to unpack .../7-libslirp0_4.6.1-1build1_amd64.deb ...
Unpacking libslirp0:amd64 (4.6.1-1build1) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../8-slirp4netns_1.0.1-2_amd64.deb ...
Unpacking slirp4netns (1.0.1-2) ...
Setting up docker-buildx-plugin (0.14.1-1~ubuntu.22.04~jammy) ...
Setting up containerd.io (1.6.33-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up docker-compose-plugin (2.27.1-1~ubuntu.22.04~jammy) ...
Setting up docker-ce-cli (5:26.1.4-1~ubuntu.22.04~jammy) ...
Setting up libslirp0:amd64 (4.6.1-1build1) ...
Setting up pigz (2.6-1) ...
Setting up docker-ce-rootless-extras (5:26.1.4-1~ubuntu.22.04~jammy) ...
Setting up slirp4netns (1.0.1-2) ...
Setting up docker-ce (5:26.1.4-1~ubuntu.22.04~jammy) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
查看docker状态
root@ubuntu:/#
root@ubuntu:/# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2024-06-14 15:20:50 CST; 5min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 6832 (dockerd)
Tasks: 9
Memory: 39.8M
CPU: 386ms
CGroup: /system.slice/docker.service
└─6832 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jun 14 15:20:45 ubuntu systemd[1]: Starting Docker Application Container Engine...
Jun 14 15:20:45 ubuntu dockerd[6832]: time="2024-06-14T15:20:45.314385132+08:00" level=info msg="Starting up"code>
Jun 14 15:20:45 ubuntu dockerd[6832]: time="2024-06-14T15:20:45.315541337+08:00" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-resolved, so using resolv.conf: /run/systemd/resolve>
Jun 14 15:20:47 ubuntu dockerd[6832]: time="2024-06-14T15:20:47.272010727+08:00" level=info msg="Loading containers: start."code>
Jun 14 15:20:49 ubuntu dockerd[6832]: time="2024-06-14T15:20:49.026575396+08:00" level=info msg="Loading containers: done."code>
Jun 14 15:20:49 ubuntu dockerd[6832]: time="2024-06-14T15:20:49.357911280+08:00" level=info msg="Docker daemon" commit=de5c9cf containerd-snapshotter=false storage-driver=overlay2 version=26.1.4code>
Jun 14 15:20:49 ubuntu dockerd[6832]: time="2024-06-14T15:20:49.358033280+08:00" level=info msg="Daemon has completed initialization"code>
Jun 14 15:20:50 ubuntu dockerd[6832]: time="2024-06-14T15:20:50.209184421+08:00" level=info msg="API listen on /run/docker.sock"code>
Jun 14 15:20:50 ubuntu systemd[1]: Started Docker Application Container Engine.
lines 1-21/21 (END)
上一篇: 若依系列(一):centos7部署若依项目;在CentOS中从零部署若依开源项目(ruoyi-vue、前后端分离)过程记录,史上最全,超级详细,最适合小白从0到1部署
下一篇: 怎么查询网络出口IP
本文标签
Ubuntu 22.04 在线安装docker报错E: Package ‘docker-ce‘ has no installation candidate
声明
本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。