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]#
郑晖同学
发布了110 篇原创文章 · 获赞 84 · 访问量 3万+
私信
关注