Centos7-Docker卸载旧的更新到新版本
时间:2022-07-22
本文章向大家介绍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]#
- 了解学习速率以及它如何提高深度学习的表现
- 分布式消息队列 RocketMQ源码解析:事务消息
- WordPress用Windows主机设置伪静态方法
- PHP页面跳转代码
- 分布式事务 TCC-Transaction 源码解析 —— 调试环境搭建
- 机器学习入门——使用python进行监督学习
- 推荐算法的介绍,第一部分——协同过滤与奇异值分解
- 在ASP中实现UNIX时间戳
- 【学术】厉害了我的哥,国外技术大咖仿造了谷歌的Arts &Culture,找到古代的“你”
- 【技巧】应赛技巧,教你如何在Kaggle比赛中排在前1%
- 熔断器 Hystrix 源码解析 —— 命令执行(一)之正常执行逻辑
- 智能主题检测与无监督机器学习:识别颜色教程
- 如何下载安装Weka机器学习工作平台
- Dubbo 源码解析 —— LoadBalance
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法