0
点赞
收藏
分享

微信扫一扫

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

文章目录

  • ​​一、安装前必读​​
  • ​​3.卸载旧版本(如果之前安装过的话)​​
  • ​​安装Docker的详细步骤​​

一、安装前必读

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

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

1.查看当前的内核版本

命令:​​uname -r​​​【Docker 部署】centos7安装Docker详细步骤(无坑版教程)_运维
我这里是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:1.6.4-3.1.el7
docker-ce.x86_64 3:20.10.15-3.el7
docker-ce-rootless-extras.x86_64 0:20.10.15-3.el7

Complete!

安装Docker的详细步骤

1.安装需要的软件包, yum-util 提供yum-config-manager功能,另两个是devicemapper驱动依赖

命令:yum install -y yum-utils device-mapper-persistent-data lvm2
【Docker 部署】centos7安装Docker详细步骤(无坑版教程)_运维_02
这里是以及下载好的

2.设置 yum 源

设置一个yum源,下面两个都可用

yum-config-manager --add-repo http://download.docker.com/linux/centos/docker-ce.repo(中央仓库)

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo(阿里仓库)

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

3.选择docker版本并安装
(1)查看可用版本有哪些

yum list docker-ce --showduplicates | sort -r
【Docker 部署】centos7安装Docker详细步骤(无坑版教程)_centos_04

(2)选择一个版本并安装:yum install docker-ce-版本号

yum -y install docker-ce-18.03.1.ce
【Docker 部署】centos7安装Docker详细步骤(无坑版教程)_运维_05

出现下图说明安装成功
【Docker 部署】centos7安装Docker详细步骤(无坑版教程)_linux_06

4.启动 Docker 并设置开机自启

systemctl start docker
systemctl enable docker
【Docker 部署】centos7安装Docker详细步骤(无坑版教程)_linux_07 查看docker版本

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


举报

相关推荐

0 条评论