Centos7-Docker卸载旧的更新到新版本

简介: Centos7-Docker卸载旧的更新到新版本

1、删除老版本

停止docker服务

systemctl stop docker

查看当前版本

rpm -qa | grep docker

卸载软件包

yum erase docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine \
                  docker-ce

删除相关配置文件

find /etc/systemd -name '*docker*' -exec rm -f {} \;
find /etc/systemd -name '*docker*' -exec rm -f {} \;
find /lib/systemd -name '*docker*' -exec rm -f {} \;
rm -rf /var/lib/docker   #删除以前已有的镜像和容器,非必要
rm -rf /var/run/docker

2、安装新版本

软件包安装

yum install -y yum-utils  device-mapper-persistent-data lvm2

添加yum源

yum-config-manager \
--add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

查看可安装的版本

yum list docker-ce --showduplicates | sort -r

安装最新版本

yum install docker-ce -y

启动并开机自启

systemctl start docker
systemctl enable docker

查看docker版本

docker version

例子:

[root@zh docker]# rpm -qa |grep docker
docker-1.13.1-108.git4ef4b30.el7.centos.x86_64
docker-common-1.13.1-108.git4ef4b30.el7.centos.x86_64
docker-client-1.13.1-108.git4ef4b30.el7.centos.x86_64
[root@zh docker]# 
[root@zh docker]# docker version
Client:
 Version:         1.13.1
 API version:     1.26
 Package version: 
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@zh docker]# yum erase docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-selinux \
>                   docker-engine-selinux \
>                   docker-engine \
>                   docker-ce
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Match for argument: docker-client-latest
No Match for argument: docker-latest
No Match for argument: docker-latest-logrotate
No Match for argument: docker-logrotate
No Match for argument: docker-engine
No Match for argument: docker-ce
Resolving Dependencies
--> Running transaction check
---> Package container-selinux.noarch 2:2.107-3.el7 will be erased
---> Package docker.x86_64 2:1.13.1-108.git4ef4b30.el7.centos will be erased
---> Package docker-client.x86_64 2:1.13.1-108.git4ef4b30.el7.centos will be erased
---> Package docker-common.x86_64 2:1.13.1-108.git4ef4b30.el7.centos will be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package            Arch    Version                              Repository
                                                                           Size
================================================================================
Removing:
 container-selinux  noarch  2:2.107-3.el7                        @extras   40 k
 docker             x86_64  2:1.13.1-108.git4ef4b30.el7.centos   @extras   65 M
 docker-client      x86_64  2:1.13.1-108.git4ef4b30.el7.centos   @extras   13 M
 docker-common      x86_64  2:1.13.1-108.git4ef4b30.el7.centos   @extras  4.4 k
Transaction Summary
================================================================================
Remove  4 Packages
Installed size: 77 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
warning: Failed to open SELinux handle.
  Erasing    : 2:docker-1.13.1-108.git4ef4b30.el7.centos.x86_64             1/4 
warning: /etc/sysconfig/docker-storage saved as /etc/sysconfig/docker-storage.rpmsave
  Erasing    : 2:docker-client-1.13.1-108.git4ef4b30.el7.centos.x86_64      2/4 
  Erasing    : 2:docker-common-1.13.1-108.git4ef4b30.el7.centos.x86_64      3/4 
  Erasing    : 2:container-selinux-2.107-3.el7.noarch                       4/4 
SELinux:  Could not open policy file <= /etc/selinux/disabled/policy/policy.31:  No such file or directory
/usr/sbin/load_policy:  Can't load policy:  No such file or directory
  Verifying  : 2:docker-common-1.13.1-108.git4ef4b30.el7.centos.x86_64      1/4 
  Verifying  : 2:docker-1.13.1-108.git4ef4b30.el7.centos.x86_64             2/4 
  Verifying  : 2:docker-client-1.13.1-108.git4ef4b30.el7.centos.x86_64      3/4 
  Verifying  : 2:container-selinux-2.107-3.el7.noarch                       4/4 
Removed:
  container-selinux.noarch 2:2.107-3.el7                                        
  docker.x86_64 2:1.13.1-108.git4ef4b30.el7.centos                              
  docker-client.x86_64 2:1.13.1-108.git4ef4b30.el7.centos                       
  docker-common.x86_64 2:1.13.1-108.git4ef4b30.el7.centos                       
Complete!
You have mail in /var/spool/mail/root
[root@zh docker]# 
[root@zh docker]# 
[root@zh docker]# docker version
-bash: /usr/bin/docker: No such file or directory
[root@zh docker]# 
[root@zh docker]# find /etc/systemd -name '*docker*' -exec rm -f {} \;
[root@zh docker]# find /etc/systemd -name '*docker*' -exec rm -f {} \;
[root@zh docker]# find /lib/systemd -name '*docker*' -exec rm -f {} \;
rm -rf /var/lib/docker   #删除以前已有的镜像和容器,非必要
[root@zh docker]# rm -rf /var/lib/docker   #删除以前已有的镜像和容器,非必要
rm -rf /var/run/docker  [root@zh docker]# rm -rf /var/run/docker  
[root@zh docker]# 
[root@zh docker]# yum install -y yum-utils  device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Determining fastest mirrors
base                                                     | 3.6 kB     00:00     
http://mirrors.cloud.aliyuncs.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
extras                                                   | 2.9 kB     00:00     
mysql-connectors-community                               | 2.5 kB     00:00     
mysql-tools-community                                    | 2.5 kB     00:00     
mysql57-community                                        | 2.5 kB     00:00     
updates                                                  | 2.9 kB     00:00     
updates/7/x86_64/primary_db                                | 6.7 MB   00:00     
Package device-mapper-persistent-data-0.8.5-1.el7.x86_64 already installed and latest version
Package 7:lvm2-2.02.185-2.el7_7.2.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-52.el7 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-52.el7.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-52.el7.noarch
--> Running transaction check
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package               Arch          Version                  Repository   Size
================================================================================
Installing:
 yum-utils             noarch        1.1.31-52.el7            base        121 k
Installing for dependencies:
 libxml2-python        x86_64        2.9.1-6.el7_2.3          base        247 k
 python-chardet        noarch        2.2.1-3.el7              base        227 k
 python-kitchen        noarch        1.1.1-5.el7              base        267 k
Transaction Summary
================================================================================
Install  1 Package (+3 Dependent packages)
Total download size: 862 k
Installed size: 4.3 M
Downloading packages:
(1/4): python-chardet-2.2.1-3.el7.noarch.rpm               | 227 kB   00:00     
(2/4): python-kitchen-1.1.1-5.el7.noarch.rpm               | 267 kB   00:00     
(3/4): yum-utils-1.1.31-52.el7.noarch.rpm                  | 121 kB   00:00     
(4/4): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm           | 247 kB   00:01     
--------------------------------------------------------------------------------
Total                                              700 kB/s | 862 kB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-chardet-2.2.1-3.el7.noarch                            1/4 
warning: Failed to open SELinux handle.
  Installing : python-kitchen-1.1.1-5.el7.noarch                            2/4 
  Installing : libxml2-python-2.9.1-6.el7_2.3.x86_64                        3/4 
  Installing : yum-utils-1.1.31-52.el7.noarch                               4/4 
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                            1/4 
  Verifying  : yum-utils-1.1.31-52.el7.noarch                               2/4 
  Verifying  : libxml2-python-2.9.1-6.el7_2.3.x86_64                        3/4 
  Verifying  : python-chardet-2.2.1-3.el7.noarch                            4/4 
Installed:
  yum-utils.noarch 0:1.1.31-52.el7                                              
Dependency Installed:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3  python-chardet.noarch 0:2.2.1-3.el7 
  python-kitchen.noarch 0:1.1.1-5.el7     
Complete!
[root@zh docker]# yum-config-manager \
> --add-repo \
>     https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@zh docker]# yum list docker-ce --showduplicates | sort -r
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
http://mirrors.cloud.aliyuncs.com/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
docker-ce.x86_64            3:19.03.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:19.03.0-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.9-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.8-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.7-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.0.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            18.03.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.12.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.09.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.3.ce-1.el7                    docker-ce-stable
docker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
Available Packages
You have new mail in /var/spool/mail/root
[root@zh docker]# 
[root@zh docker]# yum install docker-ce -y
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
epel                                                                                                                                        | 5.4 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                                                                                               | 1.0 MB  00:00:00     
(2/2): epel/x86_64/primary_db                                                                                                               | 6.7 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:19.03.6-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-19.03.6-3.el7.x86_64
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-19.03.6-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-19.03.6-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.107-3.el7 will be installed
---> Package containerd.io.x86_64 0:1.2.10-3.2.el7 will be installed
---> Package docker-ce-cli.x86_64 1:19.03.6-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package              Arch      Version               Repository           Size
================================================================================
Installing:
 docker-ce            x86_64    3:19.03.6-3.el7       docker-ce-stable     24 M
Installing for dependencies:
 container-selinux    noarch    2:2.107-3.el7         extras               39 k
 containerd.io        x86_64    1.2.10-3.2.el7        docker-ce-stable     23 M
 docker-ce-cli        x86_64    1:19.03.6-3.el7       docker-ce-stable     40 M
Transaction Summary
================================================================================
Install  1 Package (+3 Dependent packages)
Total download size: 87 M
Installed size: 363 M
Downloading packages:
(1/4): container-selinux-2.107-3.el7.noarch.rpm            |  39 kB   00:00     
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.2.10-3.2.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for containerd.io-1.2.10-3.2.el7.x86_64.rpm is not installed
(2/4): containerd.io-1.2.10-3.2.el7.x86_64.rpm             |  23 MB   00:03     
(3/4): docker-ce-19.03.6-3.el7.x86_64.rpm                  |  24 MB   00:05     
(4/4): docker-ce-cli-19.03.6-3.el7.x86_64.rpm              |  40 MB   00:04     
--------------------------------------------------------------------------------
Total                                               11 MB/s |  87 MB  00:07     
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download.docker.com/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:container-selinux-2.107-3.el7.noarch                       1/4 
warning: Failed to open SELinux handle.
Boolean virt_use_nfs is not defined
SELinux:  Could not open policy file <= /etc/selinux/disabled/policy/policy.31:  No such file or directory
/usr/sbin/load_policy:  Can't load policy:  No such file or directory
sed: can't read /etc/selinux/disabled/contexts/customizable_types: No such file or directory
  Installing : containerd.io-1.2.10-3.2.el7.x86_64                          2/4 
  Installing : 1:docker-ce-cli-19.03.6-3.el7.x86_64                         3/4 
  Installing : 3:docker-ce-19.03.6-3.el7.x86_64                             4/4 
  Verifying  : 3:docker-ce-19.03.6-3.el7.x86_64                             1/4 
  Verifying  : 1:docker-ce-cli-19.03.6-3.el7.x86_64                         2/4 
  Verifying  : containerd.io-1.2.10-3.2.el7.x86_64                          3/4 
  Verifying  : 2:container-selinux-2.107-3.el7.noarch                       4/4 
Installed:
  docker-ce.x86_64 3:19.03.6-3.el7                                              
Dependency Installed:
  container-selinux.noarch 2:2.107-3.el7  containerd.io.x86_64 0:1.2.10-3.2.el7 
  docker-ce-cli.x86_64 1:19.03.6-3.el7   
Complete!
[root@zh docker]# 
You have new mail in /var/spool/mail/root
[root@zh docker]# docker version
Client: Docker Engine - Community
 Version:           19.03.6
 API version:       1.40
 Go version:        go1.12.16
 Git commit:        369ce74a3c
 Built:             Thu Feb 13 01:29:29 2020
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@zh docker]#
目录
相关文章
|
机器人 网络安全 数据安全/隐私保护
autMan奥特曼机器人-对接Docker版本NTQQ详细教程
本文介绍了如何在服务器上搭建NTQQ机器人,通过官方NTQQ对接各框架,实现QQ登录的稳定运行。文章提到了需要准备一台服务器和相应的软件,并详细描述了通过SSH链接服务器、创建文件夹和配置文件、编辑配置文件地址端口、运行容器等步骤。同时,文章还介绍了VNC连接的使用和配置,以及使用watchtower进行NTQQ的更新。文章总结起来就是在服务器上搭建NTQQ机器人,实现QQ登录的稳定性和自动登录功能,同时提供了更新和维护的方法。
1147 3
autMan奥特曼机器人-对接Docker版本NTQQ详细教程
|
9月前
|
安全 Linux 定位技术
如何在CentOS中卸载LVM磁盘
综上,卸载LVM的过程就像是一场探险,需要小心翼翼地按照地图行动,不能偏离原定的路线。希望我手绘的这张地图对你有所帮助,让你能平安顺利地完成解除LVM的挑战。记住,整个过程中你都得小心谨慎,否则就可能会丢掉紧张刺激、惊险无比的宝石。在这个探险中,我为你解答了如何卸载LVM,提供了明确的指导和路线。人生就是一场探险,希望你在这个过程中学到的不仅仅是如何卸载LVM,更多的是如何在解决问题的过程中,认识自我,挑战自我,超越自我。那么,探险家们,还在等什么,让我们开始吧!
433 35
|
9月前
|
Linux 编译器 开发工具
提升CentOS 7中的gcc/G++版本
至此,你已经成功在CentOS 7中升级了gcc/G++版本。从现在开始,在终端中运行 `gcc`或 `g++`时,将会使用新版本的编译器。
1089 21
|
Linux 应用服务中间件 nginx
CentOS系统下的软件安装与卸载
CentOS系统中安装及卸载软件,常用yum命令安装及卸载软件包。yum是基于RPM的软件包管理器,可用于在CentOS中安装、更新、查询和移除软件包。yum命令可以从指定服务器下载rpm包并安装,能自动解决依赖问题。
575 78
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
11月前
|
监控 关系型数据库 MySQL
zabbix7.0.9安装-以宝塔安装形式-非docker容器安装方法-系统采用AlmaLinux9系统-最佳匹配操作系统提供稳定运行环境-安装教程完整版本-优雅草卓伊凡
zabbix7.0.9安装-以宝塔安装形式-非docker容器安装方法-系统采用AlmaLinux9系统-最佳匹配操作系统提供稳定运行环境-安装教程完整版本-优雅草卓伊凡
857 30
|
10月前
|
前端开发 Linux Docker
docker的安装使用0废话版本自学软硬件工程师778天
win11怎么安装docker的必要设置自学软硬件工程师778天
|
Linux 编译器 测试技术
【C++】CentOS环境搭建-快速升级G++版本
通过上述任一方法,您都可以在CentOS环境中高效地升级G++至所需的最新版本,进而利用C++的新特性,提升开发效率和代码质量。
778 64
|
Linux 编译器 测试技术
【C++】CentOS环境搭建-快速升级G++版本
通过上述任一方法,您都可以在CentOS环境中高效地升级G++至所需的最新版本,进而利用C++的新特性,提升开发效率和代码质量。
904 63
|
运维 监控 安全
CentOS 7系统 OpenSSH和OpenSSL版本升级指南
本文详细介绍如何在CentOS 7系统上升级OpenSSH和OpenSSL至最新稳定版本(OpenSSH 9.6p1和OpenSSL 1.1.1w),解决多个已知安全漏洞(如CVE-2023-51767等)。涵盖环境说明、现存漏洞、升级准备、具体步骤及故障排查,确保服务器安全。建议先在测试环境验证,再应用于生产环境。
4669 7