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]#
目录
相关文章
|
29天前
|
机器人 网络安全 数据安全/隐私保护
autMan奥特曼机器人-对接Docker版本NTQQ详细教程
本文介绍了如何在服务器上搭建NTQQ机器人,通过官方NTQQ对接各框架,实现QQ登录的稳定运行。文章提到了需要准备一台服务器和相应的软件,并详细描述了通过SSH链接服务器、创建文件夹和配置文件、编辑配置文件地址端口、运行容器等步骤。同时,文章还介绍了VNC连接的使用和配置,以及使用watchtower进行NTQQ的更新。文章总结起来就是在服务器上搭建NTQQ机器人,实现QQ登录的稳定性和自动登录功能,同时提供了更新和维护的方法。
64 3
autMan奥特曼机器人-对接Docker版本NTQQ详细教程
|
3月前
|
消息中间件 Linux API
centos7 安装rabbitmq自定义版本及配置
centos7 安装rabbitmq自定义版本及配置
|
1月前
|
Linux 编译器 测试技术
【C++】CentOS环境搭建-快速升级G++版本
通过上述任一方法,您都可以在CentOS环境中高效地升级G++至所需的最新版本,进而利用C++的新特性,提升开发效率和代码质量。
164 64
|
1月前
|
Linux 编译器 测试技术
【C++】CentOS环境搭建-快速升级G++版本
通过上述任一方法,您都可以在CentOS环境中高效地升级G++至所需的最新版本,进而利用C++的新特性,提升开发效率和代码质量。
202 63
|
1月前
|
Kubernetes Linux 开发工具
centos7通过kubeadm安装k8s 1.27.1版本
centos7通过kubeadm安装k8s 1.27.1版本
|
1月前
|
安全 Linux 编译器
Centos 7.9如何使用源码编译安装curl最新版本
通过上述步骤,您就能在CentOS 7.9上成功地从源代码编译并安装curl的最新版本。这种方法不仅提供了灵活性,允许您定制编译选项,还确保了软件的最新功能和安全更新得到应用。
61 1
|
2月前
|
Docker 容器
如何查看docker版本|12
如何查看docker版本|12
39 2
|
1月前
|
NoSQL MongoDB Docker
求助,有没有大神可以找到arm64架构下mongodb的3.6.8版本的docker镜像?
在Docker Hub受限的情况下,寻求适用于ARM架构的docker镜像资源或拉取链接,以便在x86架构上获取;内网中的机器为ARM架构,因此优先请求适合ARM的Docker镜像或Dockerfile,非常感激您的帮助。
|
3月前
|
Linux PHP
Linux CentOS 宝塔 Suhosin禁用php5.6版本eval函数详细图文教程
【8月更文挑战第27天】本文介绍两种禁用PHP执行的方法:使用`PHP_diseval_extension`禁用和通过`suhosin`禁用。由于`suhosin`不支持PHP8,仅适用于PHP7及以下版本,若服务器安装了PHP5.6,则需对应安装`suhosin-0.9.38`版本。文章提供了详细的安装步骤,并强调了宝塔环境下与普通环境下的PHP路径差异。安装完成后,在`php.ini`中添加`suhosin.so`扩展并设置`executor.disable_eval = on`以禁用执行功能。最后通过测试代码验证是否成功禁用,并重启`php-fpm`服务生效。
49 2
|
3月前
|
Linux
centos安装与卸载软件
centos安装与卸载软件
46 1
下一篇
无影云桌面