mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
88 字
1 分钟
更新 Docker
2025-03-01

当前 docker 的镜像#

[root@localhost mcp-server]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost mcp-server]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
  • 结果:没有任何镜像和已开启的docker

查看系统架构#

[root@localhost mcp-server]# echo "=== 架构 ==="; uname -m;
=== 架构 ===
x86_64
[root@localhost mcp-server]# echo -e "\n=== 内核 ==="; uname -r;
=== 内核 ===
3.10.0-957.el7.x86_64
[root@localhost mcp-server]# echo -e "\n=== 系统 ==="; cat /etc/redhat-release;
=== 系统 ===
CentOS Linux release 7.6.1810 (Core)
[root@localhost mcp-server]# echo -e "\n=== 旧组件 ==="; rpm -qa | grep -E 'docker|containerd|podman'
=== 旧组件 ===
docker-scan-plugin-0.17.0-3.el7.x86_64
containerd.io-1.6.8-3.1.el7.x86_64
docker-ce-20.10.18-3.el7.x86_64
docker-ce-cli-20.10.18-3.el7.x86_64
docker-ce-rootless-extras-20.10.18-3.el7.x86_64

查看当前docker位置(用于备份)#

[root@localhost mcp-server]# which docker
/usr/bin/docker

停止服务#

[root@localhost mcp-server]# systemctl stop docker
Warning: Stopping docker.service, but it can still be activated by: docker.socket
  • 提示还有docker.socket没有停止
[root@localhost mcp-server]# systemctl stop docker.socket

备份#

tar -zcvf /root/docker_backup.tar.gz /var/lib/docker
cp -r /etc/docker /root/etc_docker_backup

卸载旧版本#

[root@localhost mcp-server]# yum remove -y docker* containerd.io
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
正在解决依赖关系
--> 正在检查事务
---> 软件包 containerd.io.x86_64.0.1.6.8-3.1.el7 将被 删除
---> 软件包 docker-ce.x86_64.3.20.10.18-3.el7 将被 删除
---> 软件包 docker-ce-cli.x86_64.1.20.10.18-3.el7 将被 删除
---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.18-3.el7 将被 删除
---> 软件包 docker-scan-plugin.x86_64.0.0.17.0-3.el7 将被 删除
--> 解决依赖关系完成
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
http://ftp.sjtu.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
http://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bfsu.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bupt.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.bupt.edu.cn; 未知的错误"
正在尝试其它镜像。
http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.nju.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.jlu.edu.cn/centos/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] curl#52 - "Empty reply from server"
正在尝试其它镜像。
http://mirrors.cqu.edu.cn/CentOS/7.9.2009/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 503 - Service Unavailable
正在尝试其它镜像。
base/7/x86_64 | 3.6 kB 00:00:00
docker-ce-stable/7/x86_64 | 3.5 kB 00:00:00
epel/x86_64/metalink | 3.8 kB 00:00:00
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
http://ftp.sjtu.edu.cn/centos/7.9.2009/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
extras/7/x86_64 | 2.9 kB 00:00:00
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=updates&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
http://ftp.sjtu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.ustc.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.huaweicloud.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.163.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bfsu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bupt.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.bupt.edu.cn; 未知的错误"
正在尝试其它镜像。
http://mirrors.nju.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.jlu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#52 - "Empty reply from server"
正在尝试其它镜像。
http://mirrors.cqu.edu.cn/CentOS/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 503 - Service Unavailable
正在尝试其它镜像。
依赖关系解决
===================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================
正在删除:
containerd.io x86_64 1.6.8-3.1.el7 @docker-ce-stable 125 M
docker-ce x86_64 3:20.10.18-3.el7 @docker-ce-stable 84 M
docker-ce-cli x86_64 1:20.10.18-3.el7 @docker-ce-stable 129 M
docker-ce-rootless-extras x86_64 20.10.18-3.el7 @docker-ce-stable 18 M
docker-scan-plugin x86_64 0.17.0-3.el7 @docker-ce-stable 13 M
事务概要
===================================================================================================================================
移除 5 软件包
安装大小:368 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在删除 : docker-ce-rootless-extras-20.10.18-3.el7.x86_64 1/5
正在删除 : 3:docker-ce-20.10.18-3.el7.x86_64 2/5
正在删除 : 1:docker-ce-cli-20.10.18-3.el7.x86_64 3/5
正在删除 : docker-scan-plugin-0.17.0-3.el7.x86_64 4/5
正在删除 : containerd.io-1.6.8-3.1.el7.x86_64 5/5
验证中 : docker-scan-plugin-0.17.0-3.el7.x86_64 1/5
验证中 : 1:docker-ce-cli-20.10.18-3.el7.x86_64 2/5
验证中 : 3:docker-ce-20.10.18-3.el7.x86_64 3/5
验证中 : containerd.io-1.6.8-3.1.el7.x86_64 4/5
验证中 : docker-ce-rootless-extras-20.10.18-3.el7.x86_64 5/5
删除:
containerd.io.x86_64 0:1.6.8-3.1.el7 docker-ce.x86_64 3:20.10.18-3.el7 docker-ce-cli.x86_64 1:20.10.18-3.el7
docker-ce-rootless-extras.x86_64 0:20.10.18-3.el7 docker-scan-plugin.x86_64 0:0.17.0-3.el7
完毕!

更新镜像源#

[root@localhost mcp-server]# yum install -y yum-utils
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
* base: mirrors.aliyun.com
* epel: ftp-stud.hs-esslingen.de
* extras: mirrors.aliyun.com
* updates: mirrors.ustc.edu.cn
http://ftp.sjtu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
http://mirrors.huaweicloud.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.ustc.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bfsu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bupt.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.bupt.edu.cn; 未知的错误"
正在尝试其它镜像。
http://mirrors.nju.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.jlu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#52 - "Empty reply from server"
正在尝试其它镜像。
http://mirrors.163.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.cqu.edu.cn/CentOS/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 503 - Service Unavailable
正在尝试其它镜像。
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理

更新新的镜像源#

[root@localhost mcp-server]# rm -f /etc/y.repos.d/docker-ce.repo
[root@localhost mcp-server]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks, product-id, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

安装新docker 24.0.9#

[root@localhost mcp-server]# yum install -y docker-ce-24.0.9 docker-ce-cli-24.0.9 containerd.io
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: ftp-stud.hs-esslingen.de
* extras: mirrors.aliyun.com
* updates: mirrors.ustc.edu.cn
docker-ce-stable | 3.5 kB 00:00:00
http://ftp.sjtu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
http://mirrors.huaweicloud.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.ustc.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bfsu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.nju.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.bupt.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.bupt.edu.cn; 未知的错误"
正在尝试其它镜像。
http://mirrors.jlu.edu.cn/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] curl#52 - "Empty reply from server"
正在尝试其它镜像。
http://mirrors.163.com/centos/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
正在尝试其它镜像。
http://mirrors.cqu.edu.cn/CentOS/7.9.2009/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 503 - Service Unavailable
正在尝试其它镜像。
正在解决依赖关系
--> 正在检查事务
---> 软件包 containerd.io.x86_64.0.1.6.33-3.1.el7 将被 安装
---> 软件包 docker-ce.x86_64.3.24.0.9-1.el7 将被 安装
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-24.0.9-1.el7.x86_64 需要
---> 软件包 docker-ce-cli.x86_64.1.24.0.9-1.el7 将被 安装
--> 正在处理依赖关系 docker-buildx-plugin,它被软件包 1:docker-ce-cli-24.0.9-1.el7.x86_64 需要
--> 正在处理依赖关系 docker-compose-plugin,它被软件包 1:docker-ce-cli-24.0.9-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 docker-buildx-plugin.x86_64.0.0.14.1-1.el7 将被 安装
---> 软件包 docker-ce-rootless-extras.x86_64.0.26.1.4-1.el7 将被 安装
---> 软件包 docker-compose-plugin.x86_64.0.2.27.1-1.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
===================================================================================================================================
Package 架构 版本 源 大小
===================================================================================================================================
正在安装:
containerd.io x86_64 1.6.33-3.1.el7 docker-ce-stable 35 M
docker-ce x86_64 3:24.0.9-1.el7 docker-ce-stable 24 M
docker-ce-cli x86_64 1:24.0.9-1.el7 docker-ce-stable 13 M
为依赖而安装:
docker-buildx-plugin x86_64 0.14.1-1.el7 docker-ce-stable 14 M
docker-ce-rootless-extras x86_64 26.1.4-1.el7 docker-ce-stable 9.4 M
docker-compose-plugin x86_64 2.27.1-1.el7 docker-ce-stable 13 M
事务概要
===================================================================================================================================
安装 3 软件包 (+3 依赖软件包)
总计:109 M
总下载量:38 M
安装大小:385 M
Downloading packages:
No Presto metadata available for docker-ce-stable
(1/2): docker-ce-cli-24.0.9-1.el7.x86_64.rpm | 13 MB 00:00:05
(2/2): docker-ce-24.0.9-1.el7.x86_64.rpm | 24 MB 00:00:10
-----------------------------------------------------------------------------------------------------------------------------------
总计 3.7 MB/s | 38 MB 00:00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : docker-buildx-plugin-0.14.1-1.el7.x86_64 1/6
正在安装 : containerd.io-1.6.33-3.1.el7.x86_64 2/6
正在安装 : docker-compose-plugin-2.27.1-1.el7.x86_64 3/6
正在安装 : 1:docker-ce-cli-24.0.9-1.el7.x86_64 4/6
正在安装 : docker-ce-rootless-extras-26.1.4-1.el7.x86_64 5/6
正在安装 : 3:docker-ce-24.0.9-1.el7.x86_64 6/6
验证中 : docker-compose-plugin-2.27.1-1.el7.x86_64 1/6
验证中 : containerd.io-1.6.33-3.1.el7.x86_64 2/6
验证中 : 1:docker-ce-cli-24.0.9-1.el7.x86_64 3/6
验证中 : docker-ce-rootless-extras-26.1.4-1.el7.x86_64 4/6
验证中 : docker-buildx-plugin-0.14.1-1.el7.x86_64 5/6
验证中 : 3:docker-ce-24.0.9-1.el7.x86_64 6/6
已安装:
containerd.io.x86_64 0:1.6.33-3.1.el7 docker-ce.x86_64 3:24.0.9-1.el7 docker-ce-cli.x86_64 1:24.0.9-1.el7
作为依赖被安装:
docker-buildx-plugin.x86_64 0:0.14.1-1.el7 docker-ce-rootless-extras.x86_64 0:26.1.4-1.el7
docker-compose-plugin.x86_64 0:2.27.1-1.el7
完毕!
[root@localhost mcp-server]#
[root@localhost mcp-server]#
[root@localhost mcp-server]# docker --version
Docker version 24.0.9, build 2936816

设置开机自启#

[root@localhost mcp-server]# which docker
/usr/bin/docker
[root@localhost mcp-server]# systemctl start docker
[root@localhost mcp-server]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost mcp-server]# systemctl start docker.socket
[root@localhost mcp-server]# docker --version
Docker version 24.0.9, build 2936816
[root@localhost mcp-server]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@localhost mcp-server]# docker info
Client: Docker Engine - Community
Version: 24.0.9
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.14.1
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.27.1
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 24.0.9
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: d2d58213f83a351ca8f528a95fbd145f5654e957
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.49GiB
Name: localhost.localdomain
ID: 9022d3da-8d04-4a8c-a625-5769b330d119
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

配置国内镜像#

mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
EOF
systemctl daemon-reload
systemctl restart docker
分享

如果这篇文章对你有帮助,欢迎分享给更多人!

更新 Docker
https://www.403bug.top/posts/update-docker/
作者
ma
发布于
2025-03-01
许可协议
CC BY-NC-SA 4.0

部分信息可能已经过时

目录