当前位置首页 > Ubuntu知识

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

阅读次数:277 次  来源:admin  发布时间:

1.查看安装版本,我这安装的是最新的docker版本。如下:

yum list installed | grep docker

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

3.停止docker服务

[root@localhost ~]# systemctl stop docker.service

语法:yum downgrade --setopt=obsoletes=0 -y docker-ce-${version} docker-ce-selinux-${version}

注:${version}指定要降级的版本。

示例,如下(亲测有效):

[root@localhost ~]# yum downgrade --setopt=obsoletes=0 -y docker-ce-19.03.13-3.el7 docker-ce-cli-19.03.13-3.el7 containerd.io

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

3.启动并查看

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

4.Docker更新到最新版本

curl -fsSL https://get.docker.com/ | sh
yang@ubuntu:~$ curl -fsSL https://get.docker.com/ | sh
# Executing docker install script, commit: 93d2499759296ac1f9c510605fef85052a2c32be
Warning: the "docker" command appears to already exist on this system.

If you already have Docker installed, this script can cause trouble, which is
why we're displaying this warning and provide the opportunity to cancel the
installation.

If you installed the current Docker package using this script and are using it
again to update Docker, you can safely ignore this message.

You may press Ctrl+C now to abort this script.
+ sleep 20
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/ubuntu/gpg" | gpg --dearmor --yes -o /usr/share/keyrings/docker-archive-keyring.gpg
+ sudo -E sh -c echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends  docker-ce-cli docker-scan-plugin docker-ce >/dev/null
+ version_gte 20.10
+ [ -z  ]
+ return 0
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null
+ sudo -E sh -c docker version
Client: Docker Engine - Community
 Version:           20.10.11

重启并查看

yang@ubuntu:~$ sudo systemctl restart docker
yang@ubuntu:~$ docker version
Client: Docker Engine - Community
 Version:           20.10.11
 API version:       1.41
 Go version:        go1.16.9
 Git commit:        dea9396
 Built:             Thu Nov 18 00:37:06 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.11
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       847da18
  Built:            Thu Nov 18 00:35:15 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

为什么降低版本呢?

因为更新了系统后,docker也随之更新为最新版本,在rancher添加的主机上就提示【未测试Dokcer版本】,而我之前的版本是19.03,因为添加主机的时候docker版本是19.03,升级后就显示未测试Docker 版本,如下图:

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

降低版本后:

Docker高版本降低指定版本及更新到最新版本【Docker】Ubuntu20.04将Docker升级至最新版

警告自动取消!!!

所以要降低到原来的版本,说是rancher 1.6的不支持docker 20的版本,所以就先降回原来的版本!

上一篇:[Java]使用Apache的Commons-net库实现FTP操作
下一篇:二.Nginx反向代理和静态资源服务配置