在 CentOS 7.0 上安装 Docker 引擎 实操


开始在CentOS 7.0 上使用 Docker 引擎前,请先却保你的环境满足安装 Docker 引擎的安装条件,然后安装Docker。

1 安装先决条件检查

1.1 操作系统要求:

要安装Docker Engine,您需要CentOS 7、CentOS 8(stream)或CentOS 9(stream)的维护版本,不支持存档版本和测试版本。
该 centos-extras 存储库默认情况下处于启用状态,但是如果已禁用,则需要重新启用它
建议使用 overlay2 存储驱动程序。

1.2 卸载老版本

老版本的Docker 叫做 docker docker-engine .如果已经装过请卸载他们,以及相关依赖项。

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine

使用系统存在的用户admin进行操作

[sudo] admin 的密码:
已加载插件:fastestmirror, langpacks
参数 docker 没有匹配
参数 docker-client 没有匹配
参数 docker-client-latest 没有匹配
参数 docker-common 没有匹配
参数 docker-latest 没有匹配
参数 docker-latest-logrotate 没有匹配
参数 docker-logrotate 没有匹配
参数 docker-engine 没有匹配
不删除任何软件包

如果yum报告这些包都没有安装,这也没关系,继续下一步。
?? The contents of ./var/lib/docker/, including images, containers, volumes, and networks, are preserved.
现在 Docker Engine 包叫做 docker-ce

2 安装方法

您可以根据需要以不同的方式安装 Docker 引擎:
■ 大多数用户设置Docker的存储库并安装 从他们那里,以便于安装和升级任务。推荐使用该方法安装。
■ 一些用户下载 RPM 包并手动安装并管理,完全手动升级。这在一些情况下非常有用,比如在无法访问internet的物理隔离系统上安装Docker。
■ 在测试和开发环境中,一些用户选择使用自动化的便利脚本来安装 Docker。

2.1 使用存储库进行安装

在你为一台新机器对Docker Engine 进行首次安装时,你需要设置Dock 存储库,接下来,你可以从存储库安转和升级Docker。

2.1.1 设置存储库

安装 yum-utils包(谁提供了yum-config-manager实用程序)并且设置存储库

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

执行sudo yum install -y yum-utils
如果出现一下提示

[admin@localhost /]$ sudo yum install -y yum-utils
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#56 - "Recv failure: Connection reset by peer"


 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

我的机器是因为Linux机器没有进行网络准入验证,不能连接互联网,完成验证后重新执行

[admn@localhost /]$ sudo yum install -y yum-utils
[sudo] admn 的密码:
对不起,请重试。
[sudo] admn 的密码:
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.njupt.edu.cn
 * extras: mirrors.cqu.edu.cn
 * updates: mirrors.cqu.edu.cn
base                                                                                     | 3.6 kB  00:00:00     
extras                                                                                   | 2.9 kB  00:00:00     
updates                                                                                  | 2.9 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                            | 153 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                        | 249 kB  00:00:01     
(3/4): base/7/x86_64/primary_db                                                          | 6.1 MB  00:00:14     
(4/4): updates/7/x86_64/primary_db                                                       |  19 MB  00:00:27     
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理

继续

[admin@localhost /]$ sudo yum-config-manager \
>     --add-repo \
>     https://download.docker.com/linux/centos/docker-ce.repo
[sudo] admn 的密码:
已加载插件:fastestmirror, langpacks
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

2.1.2 安装 Docker Engine

  1. 安装最新版本的Docker Engine、containd和Docker Compose,或执行下一步安装特定版本:

执行以下命令

sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

如果提示接受GPG密钥,请验证指纹是否匹配060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35,如果是,则接受它。

这个命令会安装Docker,但是不会启动Docker。它还创建了一个docker组,但是,默认情况下它不会向组中添加任何用户。
执行过程和结果

[admin@localhost /]$ sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
[sudo] admn 的密码:
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.ustc.edu.cn
 * updates: mirrors.ustc.edu.cn
docker-ce-stable                                                                         | 3.5 kB  00:00:00     
(1/2): docker-ce-stable/7/x86_64/updateinfo                                              |   55 B  00:00:00     
(2/2): docker-ce-stable/7/x86_64/primary_db                                              |  91 kB  00:00:00     
正在解决依赖关系
--> 正在检查事务
---> 软件包 containerd.io.x86_64.0.1.6.14-3.1.el7 将被 安装
--> 正在处理依赖关系 container-selinux >= 2:2.74,它被软件包 containerd.io-1.6.14-3.1.el7.x86_64 需要
---> 软件包 docker-ce.x86_64.3.20.10.22-3.el7 将被 安装
--> 正在处理依赖关系 docker-ce-rootless-extras,它被软件包 3:docker-ce-20.10.22-3.el7.x86_64 需要
---> 软件包 docker-ce-cli.x86_64.1.20.10.22-3.el7 将被 安装
--> 正在处理依赖关系 docker-scan-plugin(x86-64),它被软件包 1:docker-ce-cli-20.10.22-3.el7.x86_64 需要
---> 软件包 docker-compose-plugin.x86_64.0.2.14.1-3.el7 将被 安装
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
---> 软件包 docker-ce-rootless-extras.x86_64.0.20.10.22-3.el7 将被 安装
--> 正在处理依赖关系 fuse-overlayfs >= 0.7,它被软件包 docker-ce-rootless-extras-20.10.22-3.el7.x86_64 需要
--> 正在处理依赖关系 slirp4netns >= 0.4,它被软件包 docker-ce-rootless-extras-20.10.22-3.el7.x86_64 需要
---> 软件包 docker-scan-plugin.x86_64.0.0.23.0-3.el7 将被 安装
--> 正在检查事务
---> 软件包 fuse-overlayfs.x86_64.0.0.7.2-6.el7_8 将被 安装
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.2)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3(FUSE_3.0)(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
--> 正在处理依赖关系 libfuse3.so.3()(64bit),它被软件包 fuse-overlayfs-0.7.2-6.el7_8.x86_64 需要
---> 软件包 slirp4netns.x86_64.0.0.4.3-4.el7_8 将被 安装
--> 正在检查事务
---> 软件包 fuse3-libs.x86_64.0.3.6.1-4.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

================================================================================================================
 Package                          架构          版本                              源                       大小
================================================================================================================
正在安装:
 containerd.io                    x86_64        1.6.14-3.1.el7                    docker-ce-stable         33 M
 docker-ce                        x86_64        3:20.10.22-3.el7                  docker-ce-stable         22 M
 docker-ce-cli                    x86_64        1:20.10.22-3.el7                  docker-ce-stable         30 M
 docker-compose-plugin            x86_64        2.14.1-3.el7                      docker-ce-stable         10 M
为依赖而安装:
 container-selinux                noarch        2:2.119.2-1.911c772.el7_8         extras                   40 k
 docker-ce-rootless-extras        x86_64        20.10.22-3.el7                    docker-ce-stable        8.5 M
 docker-scan-plugin               x86_64        0.23.0-3.el7                      docker-ce-stable        3.8 M
 fuse-overlayfs                   x86_64        0.7.2-6.el7_8                     extras                   54 k
 fuse3-libs                       x86_64        3.6.1-4.el7                       extras                   82 k
 slirp4netns                      x86_64        0.4.3-4.el7_8                     extras                   81 k

事务概要
================================================================================================================
安装  4 软件包 (+6 依赖软件包)

总下载量:107 M
安装大小:398 M
Is this ok [y/d/N]: y
Downloading packages:
警告:/var/cache/yum/x86_64/7/extras/packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm 的公钥尚未安装
(1/10): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                             |  40 kB  00:00:00     
警告:/var/cache/yum/x86_64/7/docker-ce-stable/packages/containerd.io-1.6.14-3.1.el7.x86_64.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 621e9f35: NOKEY
containerd.io-1.6.14-3.1.el7.x86_64.rpm 的公钥尚未安装
(2/10): containerd.io-1.6.14-3.1.el7.x86_64.rpm                                          |  33 MB  00:00:45     
(3/10): docker-ce-20.10.22-3.el7.x86_64.rpm                                              |  22 MB  00:00:49     
(4/10): docker-ce-rootless-extras-20.10.22-3.el7.x86_64.rpm                              | 8.5 MB  00:00:18     
(5/10): docker-compose-plugin-2.14.1-3.el7.x86_64.rpm                                    |  10 MB  00:00:20     
(6/10): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm                                          |  54 kB  00:00:00     
(7/10): docker-ce-cli-20.10.22-3.el7.x86_64.rpm                                          |  30 MB  00:00:44     
(8/10): slirp4netns-0.4.3-4.el7_8.x86_64.rpm                                             |  81 kB  00:00:00     
(9/10): fuse3-libs-3.6.1-4.el7.x86_64.rpm                                                |  82 kB  00:00:03     
(10/10): docker-scan-plugin-0.23.0-3.el7.x86_64.rpm                                      | 3.8 MB  00:00:03     
----------------------------------------------------------------------------------------------------------------
总计                                                                            1.2 MB/s | 107 MB  00:01:33     
从 https://download.docker.com/linux/centos/gpg 检索密钥
导入 GPG key 0x621E9F35:
 用户ID     : "Docker Release (CE rpm) <docker@docker.com>"
 指纹       : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 来自       : https://download.docker.com/linux/centos/gpg
是否继续?[y/N]:y
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 检索密钥
导入 GPG key 0xF4A80EB5:
 用户ID     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 指纹       : 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 软件包     : centos-release-7-9.2009.0.el7.centos.x86_64 (@anaconda)
 来自       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                         1/10 
  正在安装    : containerd.io-1.6.14-3.1.el7.x86_64                                                        2/10 
  正在安装    : fuse3-libs-3.6.1-4.el7.x86_64                                                              3/10 
  正在安装    : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                        4/10 
  正在安装    : slirp4netns-0.4.3-4.el7_8.x86_64                                                           5/10 
  正在安装    : docker-scan-plugin-0.23.0-3.el7.x86_64                                                     6/10 
  正在安装    : 1:docker-ce-cli-20.10.22-3.el7.x86_64                                                      7/10 
  正在安装    : docker-ce-rootless-extras-20.10.22-3.el7.x86_64                                            8/10 
  正在安装    : 3:docker-ce-20.10.22-3.el7.x86_64                                                          9/10 
  正在安装    : docker-compose-plugin-2.14.1-3.el7.x86_64                                                 10/10 
  验证中      : 3:docker-ce-20.10.22-3.el7.x86_64                                                          1/10 
  验证中      : docker-scan-plugin-0.23.0-3.el7.x86_64                                                     2/10 
  验证中      : docker-ce-rootless-extras-20.10.22-3.el7.x86_64                                            3/10 
  验证中      : fuse-overlayfs-0.7.2-6.el7_8.x86_64                                                        4/10 
  验证中      : slirp4netns-0.4.3-4.el7_8.x86_64                                                           5/10 
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                         6/10 
  验证中      : 1:docker-ce-cli-20.10.22-3.el7.x86_64                                                      7/10 
  验证中      : containerd.io-1.6.14-3.1.el7.x86_64                                                        8/10 
  验证中      : fuse3-libs-3.6.1-4.el7.x86_64                                                              9/10 
  验证中      : docker-compose-plugin-2.14.1-3.el7.x86_64                                                 10/10 

已安装:
  containerd.io.x86_64 0:1.6.14-3.1.el7               docker-ce.x86_64 3:20.10.22-3.el7                        
  docker-ce-cli.x86_64 1:20.10.22-3.el7               docker-compose-plugin.x86_64 0:2.14.1-3.el7              

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8      docker-ce-rootless-extras.x86_64 0:20.10.22-3.el7     
  docker-scan-plugin.x86_64 0:0.23.0-3.el7                fuse-overlayfs.x86_64 0:0.7.2-6.el7_8                 
  fuse3-libs.x86_64 0:3.6.1-4.el7                         slirp4netns.x86_64 0:0.4.3-4.el7_8                    

完毕!
[admn@localhost /]$ 

  1. 安装特定版本的 Docker Engine, 列出repo中可用的版本,然后选择并安装:

1)列出并排序存储库中可用的版本。这个命令返回的结构根据版本号进行排序,并且从最高到最低列出:

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

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.1.ce-3.el7                    docker-ce-stable
docker-ce.x86_64  18.06.0.ce-3.el7                    docker-ce-stable

返回的列表取决于启用了哪些存储库,并且特定于您的CentOS版本(在本例中由.el7后缀表示)。
2)通过完全限定的包名安装特定版本,包名(docker-ce)加上版本字符串(第二列),从第一个冒号(:)开始,直到第一个连字符,用连字符(-)分隔。例如:docker-ce-18.06.1。

sudo yum install docker-ce-<docker-ce-18.06.1> docker-ce-cli-<docker-ce-18.06.1> containerd.io docker-compose-plugin

这个命令会安装Docker,但是不会启动Docker。它还创建了一个docker组,但是,默认情况下它不会向组中添加任何用户。

  1. 启动 Docker.
sudo systemctl start docker

查看Docker是否成功启动

[admin@localhost /]$ sudo systemctl start docker
[sudo] admin 的密码:
[admin@localhost /]$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
  Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  Active: active (running) since 六 2023-01-07 13:28:08 CST; 2min 5s ago
    Docs: https://docs.docker.com
Main PID: 15917 (dockerd)
   Tasks: 9
  Memory: 29.9M
  CGroup: /system.slice/docker.service
          └─15917 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

1月 07 13:28:05 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:05.214252976+08:00" level=in...rpc
1月 07 13:28:05 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:05.214270173+08:00" level=in...rpc
1月 07 13:28:06 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:06.000229001+08:00" level=in...t."
1月 07 13:28:07 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:07.377687263+08:00" level=in...ss"
1月 07 13:28:07 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:07.479759777+08:00" level=in...ng"
1月 07 13:28:07 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:07.812710007+08:00" level=in...e."
1月 07 13:28:08 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:08.017195496+08:00" level=in....22
1月 07 13:28:08 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:08.017924930+08:00" level=in...on"
1月 07 13:28:08 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
1月 07 13:28:08 localhost.localdomain dockerd[15917]: time="2023-01-07T13:28:08.378262872+08:00" level=in...ck"
Hint: Some lines were ellipsized, use -l to show in full.
  1. 运行hello-world镜像,验证Docker引擎是否正确安装。
sudo docker run hello-world

这个命令下载一个测试映像,并在容器中运行它。当容器运行时,它打印一条消息并退出。

执行结果

[admn@localhost /]$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:94ebc7edf3401f299cd3376a1669bc0a49aef92d6d2669005f9bc5ef028dc333
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
   (amd64)
3. The Docker daemon created a new container from that image which runs the
   executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
   to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/


验证成功

本次使用存储库进行安装,安装并运行Docker引擎。使用sudo运行Docker命令。继续执行Linux postinstall以允许非特权用户运行Docker命令并执行其他可选配置步骤。

2.1.3 升级 Docker Engine

要升级Docker引擎,请按照安装说明,选择您想要安装的新版本。

2.2 从下载的安装包安装

如果你不能使用Docker的存储库来安装Docker,你可以下载你的版本的.rpm文件并手动安装。每次升级Docker引擎时,您都需要下载一个新文件。

  1. 访问https://download.docker.com/linux/centos/并选择您的CentOS版本。然后浏览到x86_64/stable/Packages/目录,下载你要安装的Docker版本的.rpm文件
  2. 安装Docker引擎,将下面的路径更改为您下载Docker包的路径。
sudo yum install /path/to/package.rpm
  1. 启动 Docker.
sudo systemctl start docker
  1. 运行hello-world镜像,验证Docker引擎是否正确安装。
sudo docker run hello-world

这个命令下载一个测试映像,并在容器中运行它。当容器运行时,它打印一条消息并退出。

使用安装包方式安装并运行Docker引擎。使用sudo运行Docker命令。继续Linux的安装后步骤,以允许非特权用户运行Docker命令和其他可选配置步骤。

2.2 升级 Docker Engine

升级 Docker Engine, 下载更新的包文件并重复安装过程,使用yum -y upgrade而不是yum -y install,并指向新文件。

3 使用便利脚本进行安装

Docker在https://get.docker.com/上提供了一个方便的脚本,可以非交互式地将Docker安装到开发环境中。不建议在生产环境中使用便利脚本,但它对于创建适合您需求的配置脚本非常有用。还请参考使用存储库安装步骤,以了解使用包存储库安装的安装步骤。该脚本的源代码是开源的,可以在GitHub上的docker-install存储库中找到。

  1. 在本地运行从互联网下载的脚本之前,一定要检查脚本。在安装之前,请熟悉便捷性脚本的潜在风险和限制:
  2. 该脚本需要root或sudo权限才能运行。 该脚本试图检测您的Linux发行版和版本,并为您配置包管理系统。
  3. 该脚本不允许您自定义大多数安装参数。 脚本安装依赖项和建议而不需要确认。这可能会安装大量的包,具体取决于主机的当前配置
  4. 默认情况下,脚本会安装Docker、containd和runc的最新稳定版本。使用此脚本配置机器时,可能会导致Docker出现意外的重大版本升级。在将升级部署到生产系统之前,始终在测试环境中测试升级。
  5. 该脚本不是为升级现有Docker安装而设计的。使用脚本更新现有安装时,依赖项可能不会更新到预期的版本,从而导致版本过时。

3.1安装提示

3.1.1 运行前预览脚本步骤

您可以使用DRY_RUN=1选项运行脚本,以了解脚本在调用时将运行哪些步骤:

curl -fsSL https://get.docker.com -o get-docker.sh
DRY_RUN=1 sudo sh ./get-docker.sh

这个例子从https://get.docker.com/下载脚本,并运行它来安装Linux上最新的稳定版本的Docker:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
Executing docker install script, commit: 7cae5f8b0decc17d6571f9f52eb840fbc13b2737
<...>

现在,您已经成功安装并启动了Docker引擎。docker服务在基于Debian的发行版上自动启动。在基于RPM的发行版上,例如CentOS、Fedora、RHEL或SLES,您需要使用适当的systemctl或service命令手动启动它。如提示所示,默认情况下,非root用户不能运行Docker命令。

3.1.2以非特权用户使用Docker,还是以无根模式安装

安装脚本需要root或sudo权限才能安装和使用Docker。如果您想授予非root用户对Docker的访问权限,请参考Linux的安装后步骤。您也可以在没有root权限的情况下安装Docker,或者配置为以无root模式运行。有关在无根模式下运行Docker的说明,请参考以非根用户(无根模式)运行Docker守护进程。

3.2 安装预发行版

Docker还在https://test.docker.com/上提供了一个方便的脚本,用于在Linux上安装预先发布的Docker。这个脚本与get.docker.com上的脚本相同,但是将您的包管理器配置为使用Docker包存储库的测试通道。测试通道包括Docker的稳定版和预发布版(beta版,候选发布版)。使用此脚本可以尽早访问新版本,并在稳定发布之前在测试环境中对其进行评估。

要从测试通道安装最新版本的Linux Docker,请运行:

curl -fsSL https://test.docker.com -o test-docker.sh
sudo sh test-docker.sh

3.3使用便利脚本后升级Docker

如果您使用方便脚本安装Docker,则应该直接使用包管理器升级Docker。重新运行方便脚本没有任何好处。如果它试图重新安装主机上已经存在的存储库,那么重新运行它可能会导致问题。

4 卸载 Docker Engine

4.1 卸载Docker Engine、CLI、Containerd和Docker Compose包:

sudo yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin

4.2 主机上的Images, containers, volumes或自定义配置文件不会自动删除。需要删除所有镜像、容器和卷。

sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

必须手动删除已编辑的配置文件。

Next steps
Continue to Post-installation steps for Linux.
Review the topics in Develop with Docker to learn how to build new applications using Docker.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值