Docker 部署centos7安装Docker详细步骤(无坑版教程)

Posted zgrjddd

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker 部署centos7安装Docker详细步骤(无坑版教程)相关的知识,希望对你有一定的参考价值。

文章目录

一、安装前必读

在安装 Docker 之前,先说一下配置,我这里是Centos7
Linux 内核:官方建议 3.10 以上,3.8以上貌似也可。

注意:本文的命令使用的是 root 用户登录执行,不是 root 的话所有命令前面要加 sudo

1.查看当前的内核版本

命令:uname -r

我这里是4.19.x,满足条件。

2.使用 root 权限更新 yum 包(生产环境中此步操作需慎重,看自己情况,学习的话随便搞)

命令:yum -y update

[root@qbi-driver-01 ~]# yum -y update
Loaded plugins: fastestmirror, langpacks, releasever-adapter, update-motd
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.03.1.ce-1.el7.centos will be updated
---> Package docker-ce.x86_64 3:20.10.15-3.el7 will be an update
--> Processing Dependency: containerd.io >= 1.4.1 for package: 3:docker-ce-20.10.15-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-20.10.15-3.el7.x86_64
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.15-3.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.4-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:20.10.15-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.15-3.el7.x86_64
---> Package docker-ce-rootless-extras.x86_64 0:20.10.15-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.15-3.el7.x86_64
--> Running transaction check
---> Package docker-scan-plugin.x86_64 0:0.17.0-3.el7 will be installed
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.2.al7 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.2.al7.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.2.al7.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.2.al7.x86_64
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package                    Arch    Version            Repository         Size
===============================================================================
Updating:
 docker-ce                  x86_64  3:20.10.15-3.el7   docker-ce-stable   22 M
Installing for dependencies:
 containerd.io              x86_64  1.6.4-3.1.el7      docker-ce-stable   33 M
 docker-ce-cli              x86_64  1:20.10.15-3.el7   docker-ce-stable   29 M
 docker-ce-rootless-extras  x86_64  20.10.15-3.el7     docker-ce-stable  8.2 M
 docker-scan-plugin         x86_64  0.17.0-3.el7       docker-ce-stable  3.7 M
 fuse-overlayfs             x86_64  0.7.2-6.2.al7      extras             55 k
 fuse3-libs                 x86_64  3.6.1-2.el7        epel               82 k

Transaction Summary
===============================================================================
Install             ( 6 Dependent packages)
Upgrade  1 Package

Total download size: 97 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/7): docker-ce-20.10.15-3.el7.x86_64.rpm                |  22 MB   00:02
(2/7): containerd.io-1.6.4-3.1.el7.x86_64.rpm             |  33 MB   00:04
(3/7): docker-ce-rootless-extras-20.10.15-3.el7.x86_64.rp | 8.2 MB   00:01
(4/7): fuse-overlayfs-0.7.2-6.2.al7.x86_64.rpm            |  55 kB   00:00
(5/7): fuse3-libs-3.6.1-2.el7.x86_64.rpm                  |  82 kB   00:00
(6/7): docker-ce-cli-20.10.15-3.el7.x86_64.rpm            |  29 MB   00:04
(7/7): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm         | 3.7 MB   00:00
-------------------------------------------------------------------------------
Total                                              14 MB/s |  97 MB  00:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : docker-scan-plugin-0.17.0-3.el7.x86_64                      1/8
  Installing : 1:docker-ce-cli-20.10.15-3.el7.x86_64                       2/8
  Installing : containerd.io-1.6.4-3.1.el7.x86_64                          3/8
  Installing : fuse3-libs-3.6.1-2.el7.x86_64                               4/8
  Installing : fuse-overlayfs-0.7.2-6.2.al7.x86_64                         5/8
  Installing : docker-ce-rootless-extras-20.10.15-3.el7.x86_64             6/8
  Updating   : 3:docker-ce-20.10.15-3.el7.x86_64                           7/8
  Cleanup    : docker-ce-18.03.1.ce-1.el7.centos.x86_64                    8/8
  Verifying  : 1:docker-ce-cli-20.10.15-3.el7.x86_64                       1/8
  Verifying  : fuse3-libs-3.6.1-2.el7.x86_64                               2/8
  Verifying  : docker-ce-rootless-extras-20.10.15-3.el7.x86_64             3/8
  Verifying  : containerd.io-1.6.4-3.1.el7.x86_64                          4/8
  Verifying  : docker-scan-plugin-0.17.0-3.el7.x86_64                      5/8
  Verifying  : 3:docker-ce-20.10.15-3.el7.x86_64                           6/8
  Verifying  : fuse-overlayfs-0.7.2-6.2.al7.x86_64                         7/8
  Verifying  : docker-ce-18.03.1.ce-1.el7.centos.x86_64                    8/8

Dependency Installed:
  containerd.io.x86_64 0:1.6.4-3.1.el7
  docker-ce-cli.x86_64 1:20.10.15-3.el7
  docker-ce-rootless-extras.x86_64 0:20.10.15-3.el7
  docker-scan-plugin.x86_64 0:0.17.0-3.el7
  fuse-overlayfs.x86_64 0:0.7.2-6.2.al7
  fuse3-libs.x86_64 0:3.6.1-2.el7

Updated:
  docker-ce.x86_64 3:20.10.15-3.el7

Complete!

这个命令不是必须执行的,看个人情况,后面出现不兼容的情况的话就必须update了

注意​ 
yum -y update:升级所有包同时也升级软件和系统内核;​ 
yum -y upgrade:只升级所有包,不升级软件和系统内核

3.卸载旧版本(如果之前安装过的话)

命令:yum remove docker docker-common docker-selinux docker-engine

[root@qbi-driver-01 ~]# yum remove docker  docker-common docker-selinux docker-engine
Loaded plugins: fastestmirror, langpacks, releasever-adapter, update-motd
No Match for argument: docker
No Match for argument: docker-common
No Match for argument: docker-engine
Resolving Dependencies
--> Running transaction check
---> Package container-selinux.noarch 2:2.107-3.1.al7 will be erased
--> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.15-3.el7.x86_64
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.6.4-3.1.el7.x86_64
--> Running transaction check
---> Package containerd.io.x86_64 0:1.6.4-3.1.el7 will be erased
---> Package docker-ce.x86_64 3:20.10.15-3.el7 will be erased
--> Processing Dependency: docker-ce for package: docker-ce-rootless-extras-20.10.15-3.el7.x86_64
--> Running transaction check
---> Package docker-ce-rootless-extras.x86_64 0:20.10.15-3.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================
 Package                    Arch    Version           Repository          Size
===============================================================================
Removing:
 container-selinux          noarch  2:2.107-3.1.al7   @extras             40 k
Removing for dependencies:
 containerd.io              x86_64  1.6.4-3.1.el7     @docker-ce-stable  125 M
 docker-ce                  x86_64  3:20.10.15-3.el7  @docker-ce-stable   95 M
 docker-ce-rootless-extras  x86_64  20.10.15-3.el7    @docker-ce-stable   19 M

Transaction Summary
===============================================================================
Remove  1 Package (+3 Dependent packages)

Installed size: 239 M
Is this ok [y/N]: Y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 3:docker-ce-20.10.15-3.el7.x86_64                           1/4
  Erasing    : docker-ce-rootless-extras-20.10.15-3.el7.x86_64             2/4
  Erasing    : containerd.io-1.6.4-3.1.el7.x86_64                          3/4
  Erasing    : 2:container-selinux-2.107-3.1.al7.noarch                    4/4
  Verifying  : 2:container-selinux-2.107-3.1.al7.noarch                    1/4
  Verifying  : docker-ce-rootless-extras-20.10.15-3.el7.x86_64             2/4
  Verifying  : containerd.io-1.6.4-3.1.el7.x86_64                          3/4
  Verifying  : 3:docker-ce-20.10.15-3.el7.x86_64                           4/4

Removed:
  container-selinux.noarch 2:2.107-3.1.al7

Dependency Removed:
  containerd.io.x86_64 0以上是关于Docker 部署centos7安装Docker详细步骤(无坑版教程)的主要内容,如果未能解决你的问题,请参考以下文章

最新Docker在Centos7下安装部署(参考官方教程文档)

#gStore-weekly | Centos7系统下gStore在 docker上的安装部署

CentOS7.3服务器内网离线部署docker和容器

Centos7.3 Docker安装部署学习记录1

Docker 部署centos7安装Docker详细步骤(无坑版教程)

CentOS7.7下docker部署OpenWAF