简介
yum
是 Linux 的在线安装方式,是比较方便的。
由于 yum
是在线安装,需要从网络获取数据,所以得先保证系统是能联网的,否则一定会安装失败。
这里使用安装 Docker 作为示例。
操作
安装
官网安装参考手册:https://docs.docker.com/install/linux/docker-ce/centos/
yum -y install
语法
yum -y install 程序名
参数
-y
:所有的 yes / no 都选择 yes,确定安装时都选择 yes 时可以使用,可以省去一些选择步骤。
系统版本检测
本次示例基于 CentOS 7 进行演示,所以需要先确认系统的版本。
[root@sail ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
安装运行环境
由于 Docker 是基于 C 和 C++ 开发的,所以需要先安装相关环境。
- 安装 C 环境。使用如下命令:
yum -y install gcc
[root@sail ~]# yum -y install gcc
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): epel/x86_64/group_gz | 96 kB 00:00:00
(2/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(3/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(4/7): extras/7/x86_64/primary_db | 243 kB 00:00:00
(5/7): epel/x86_64/primary_db | 7.0 MB 00:00:00
(6/7): updates/7/x86_64/primary_db | 12 MB 00:00:00
(7/7): base/7/x86_64/primary_db | 6.1 MB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package gcc.x86_64 0:4.8.5-44.el7 will be an update
--> Processing Dependency: libgomp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: cpp = 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Processing Dependency: libgcc >= 4.8.5-44.el7 for package: gcc-4.8.5-44.el7.x86_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package cpp.x86_64 0:4.8.5-44.el7 will be an update
---> Package libgcc.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libgcc.x86_64 0:4.8.5-44.el7 will be an update
---> Package libgomp.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libgomp.x86_64 0:4.8.5-44.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Updating:
gcc x86_64 4.8.5-44.el7 base 16 M
Updating for dependencies:
cpp x86_64 4.8.5-44.el7 base 5.9 M
libgcc x86_64 4.8.5-44.el7 base 103 k
libgomp x86_64 4.8.5-44.el7 base 159 k
Transaction Summary
==================================================================================================================================================================================================
Upgrade 1 Package (+3 Dependent packages)
Total download size: 22 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): cpp-4.8.5-44.el7.x86_64.rpm | 5.9 MB 00:00:00
(2/4): libgcc-4.8.5-44.el7.x86_64.rpm | 103 kB 00:00:00
(3/4): libgomp-4.8.5-44.el7.x86_64.rpm | 159 kB 00:00:00
(4/4): gcc-4.8.5-44.el7.x86_64.rpm | 16 MB 00:00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 32 MB/s | 22 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Updating : libgomp-4.8.5-44.el7.x86_64 1/8
Updating : libgcc-4.8.5-44.el7.x86_64 2/8
Updating : cpp-4.8.5-44.el7.x86_64 3/8
Updating : gcc-4.8.5-44.el7.x86_64 4/8
Cleanup : gcc-4.8.5-36.el7_6.2.x86_64 5/8
Cleanup : cpp-4.8.5-36.el7_6.2.x86_64 6/8
Cleanup : libgcc-4.8.5-36.el7_6.2.x86_64 7/8
Cleanup : libgomp-4.8.5-36.el7_6.2.x86_64 8/8
Verifying : cpp-4.8.5-44.el7.x86_64 1/8
Verifying : gcc-4.8.5-44.el7.x86_64 2/8
Verifying : libgcc-4.8.5-44.el7.x86_64 3/8
Verifying : libgomp-4.8.5-44.el7.x86_64 4/8
Verifying : libgcc-4.8.5-36.el7_6.2.x86_64 5/8
Verifying : libgomp-4.8.5-36.el7_6.2.x86_64 6/8
Verifying : cpp-4.8.5-36.el7_6.2.x86_64 7/8
Verifying : gcc-4.8.5-36.el7_6.2.x86_64 8/8
Updated:
gcc.x86_64 0:4.8.5-44.el7
Dependency Updated:
cpp.x86_64 0:4.8.5-44.el7 libgcc.x86_64 0:4.8.5-44.el7 libgomp.x86_64 0:4.8.5-44.el7
Complete!
- 安装 C++ 环境。使用如下命令:
yum -y install gcc-c++
[root@sail ~]# yum -y install gcc-c++
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gcc-c++.x86_64 0:4.8.5-44.el7 will be installed
--> Processing Dependency: libstdc++-devel = 4.8.5-44.el7 for package: gcc-c++-4.8.5-44.el7.x86_64
--> Processing Dependency: libstdc++ = 4.8.5-44.el7 for package: gcc-c++-4.8.5-44.el7.x86_64
--> Running transaction check
---> Package libstdc++.x86_64 0:4.8.5-36.el7_6.2 will be updated
---> Package libstdc++.x86_64 0:4.8.5-44.el7 will be an update
---> Package libstdc++-devel.x86_64 0:4.8.5-44.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Installing:
gcc-c++ x86_64 4.8.5-44.el7 base 7.2 M
Installing for dependencies:
libstdc++-devel x86_64 4.8.5-44.el7 base 1.5 M
Updating for dependencies:
libstdc++ x86_64 4.8.5-44.el7 base 306 k
Transaction Summary
==================================================================================================================================================================================================
Install 1 Package (+1 Dependent package)
Upgrade ( 1 Dependent package)
Total download size: 9.0 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): libstdc++-4.8.5-44.el7.x86_64.rpm | 306 kB 00:00:00
(2/3): libstdc++-devel-4.8.5-44.el7.x86_64.rpm | 1.5 MB 00:00:00
(3/3): gcc-c++-4.8.5-44.el7.x86_64.rpm | 7.2 MB 00:00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 57 MB/s | 9.0 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : libstdc++-4.8.5-44.el7.x86_64 1/4
Installing : libstdc++-devel-4.8.5-44.el7.x86_64 2/4
Installing : gcc-c++-4.8.5-44.el7.x86_64 3/4
Cleanup : libstdc++-4.8.5-36.el7_6.2.x86_64 4/4
Verifying : libstdc++-4.8.5-44.el7.x86_64 1/4
Verifying : gcc-c++-4.8.5-44.el7.x86_64 2/4
Verifying : libstdc++-devel-4.8.5-44.el7.x86_64 3/4
Verifying : libstdc++-4.8.5-36.el7_6.2.x86_64 4/4
Installed:
gcc-c++.x86_64 0:4.8.5-44.el7
Dependency Installed:
libstdc++-devel.x86_64 0:4.8.5-44.el7
Dependency Updated:
libstdc++.x86_64 0:4.8.5-44.el7
Complete!
卸载以前的 Docker
为避免版本之间的冲突,这里建议先卸载以前的版本再进行安装。
[root@sail ~]# yum -y remove docker docker-common docker-selinux docker-engine
Loaded plugins: fastestmirror
No Match for argument: docker
No Match for argument: docker-common
No Match for argument: docker-selinux
No Match for argument: docker-engine
No Packages marked for removal
由于这里之前没有安装过 Docker,所以显示没有匹配到。
环境准备
根据 Docker 官网的建议,需要先安装一些环境。
yum install -y yum-utils device-mapper-persistent-data lvm2
[root@sail ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 will be installed
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64
---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be installed
--> Processing Dependency: lvm2-libs = 7:2.02.187-6.el7_9.5 for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: liblvm2app.so.2.2(Base)(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02(Base)(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: liblvm2app.so.2.2()(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Processing Dependency: libdevmapper-event.so.1.02()(64bit) for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-54.el7_8.noarch
--> Running transaction check
---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be installed
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_9.6 will be installed
--> Processing Dependency: libxml2 = 2.9.1-6.el7_9.6 for package: libxml2-python-2.9.1-6.el7_9.6.x86_64
---> Package lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 will be installed
--> Processing Dependency: device-mapper-event = 7:1.02.170-6.el7_9.5 for package: 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64
---> 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 device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be installed
--> Processing Dependency: device-mapper = 7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
---> Package libxml2.x86_64 0:2.9.1-6.el7_2.3 will be updated
---> Package libxml2.x86_64 0:2.9.1-6.el7_9.6 will be an update
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.149-10.el7_6.8 will be updated
--> Processing Dependency: device-mapper = 7:1.02.149-10.el7_6.8 for package: 7:device-mapper-libs-1.02.149-10.el7_6.8.x86_64
---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.149-10.el7_6.8 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================
Installing:
device-mapper-persistent-data x86_64 0.8.5-3.el7_9.2 updates 423 k
lvm2 x86_64 7:2.02.187-6.el7_9.5 updates 1.3 M
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Installing for dependencies:
device-mapper-event x86_64 7:1.02.170-6.el7_9.5 updates 192 k
device-mapper-event-libs x86_64 7:1.02.170-6.el7_9.5 updates 192 k
libaio x86_64 0.3.109-13.el7 base 24 k
libxml2-python x86_64 2.9.1-6.el7_9.6 updates 247 k
lvm2-libs x86_64 7:2.02.187-6.el7_9.5 updates 1.1 M
python-chardet noarch 2.2.1-3.el7 base 227 k
python-kitchen noarch 1.1.1-5.el7 base 267 k
Updating for dependencies:
device-mapper x86_64 7:1.02.170-6.el7_9.5 updates 297 k
device-mapper-libs x86_64 7:1.02.170-6.el7_9.5 updates 325 k
libxml2 x86_64 2.9.1-6.el7_9.6 updates 668 k
Transaction Summary
==================================================================================================================================================================================================
Install 3 Packages (+7 Dependent packages)
Upgrade ( 3 Dependent packages)
Total download size: 5.3 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/13): device-mapper-event-1.02.170-6.el7_9.5.x86_64.rpm | 192 kB 00:00:00
(2/13): device-mapper-1.02.170-6.el7_9.5.x86_64.rpm | 297 kB 00:00:00
(3/13): device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64.rpm | 192 kB 00:00:00
(4/13): device-mapper-libs-1.02.170-6.el7_9.5.x86_64.rpm | 325 kB 00:00:00
(5/13): device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64.rpm | 423 kB 00:00:00
(6/13): libxml2-python-2.9.1-6.el7_9.6.x86_64.rpm | 247 kB 00:00:00
(7/13): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
(8/13): libxml2-2.9.1-6.el7_9.6.x86_64.rpm | 668 kB 00:00:00
(9/13): lvm2-libs-2.02.187-6.el7_9.5.x86_64.rpm | 1.1 MB 00:00:00
(10/13): python-chardet-2.2.1-3.el7.noarch.rpm | 227 kB 00:00:00
(11/13): lvm2-2.02.187-6.el7_9.5.x86_64.rpm | 1.3 MB 00:00:00
(12/13): yum-utils-1.1.31-54.el7_8.noarch.rpm | 122 kB 00:00:00
(13/13): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 23 MB/s | 5.3 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libaio-0.3.109-13.el7.x86_64 1/16
Updating : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 2/16
Updating : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 3/16
Installing : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 4/16
Installing : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 5/16
Installing : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 6/16
Installing : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 7/16
Updating : libxml2-2.9.1-6.el7_9.6.x86_64 8/16
Installing : libxml2-python-2.9.1-6.el7_9.6.x86_64 9/16
Installing : python-chardet-2.2.1-3.el7.noarch 10/16
Installing : python-kitchen-1.1.1-5.el7.noarch 11/16
Installing : yum-utils-1.1.31-54.el7_8.noarch 12/16
Installing : 7:lvm2-2.02.187-6.el7_9.5.x86_64 13/16
Cleanup : 7:device-mapper-libs-1.02.149-10.el7_6.8.x86_64 14/16
Cleanup : 7:device-mapper-1.02.149-10.el7_6.8.x86_64 15/16
Cleanup : libxml2-2.9.1-6.el7_2.3.x86_64 16/16
Verifying : 7:lvm2-2.02.187-6.el7_9.5.x86_64 1/16
Verifying : python-chardet-2.2.1-3.el7.noarch 2/16
Verifying : libxml2-2.9.1-6.el7_9.6.x86_64 3/16
Verifying : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 4/16
Verifying : libxml2-python-2.9.1-6.el7_9.6.x86_64 5/16
Verifying : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 6/16
Verifying : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 7/16
Verifying : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 8/16
Verifying : python-kitchen-1.1.1-5.el7.noarch 9/16
Verifying : libaio-0.3.109-13.el7.x86_64 10/16
Verifying : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 11/16
Verifying : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 12/16
Verifying : yum-utils-1.1.31-54.el7_8.noarch 13/16
Verifying : 7:device-mapper-libs-1.02.149-10.el7_6.8.x86_64 14/16
Verifying : libxml2-2.9.1-6.el7_2.3.x86_64 15/16
Verifying : 7:device-mapper-1.02.149-10.el7_6.8.x86_64 16/16
Installed:
device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 lvm2.x86_64 7:2.02.187-6.el7_9.5 yum-utils.noarch 0:1.1.31-54.el7_8
Dependency Installed:
device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 libaio.x86_64 0:0.3.109-13.el7 libxml2-python.x86_64 0:2.9.1-6.el7_9.6
lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 python-chardet.noarch 0:2.2.1-3.el7 python-kitchen.noarch 0:1.1.1-5.el7
Dependency Updated:
device-mapper.x86_64 7:1.02.170-6.el7_9.5 device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 libxml2.x86_64 0:2.9.1-6.el7_9.6
Complete!
设置镜像仓库
这里官网建议我们安装国外的镜像仓库
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
但由于对国外的网络限制,国内安装的话会非常慢,并很有可能失败,报如下错误。
[Errno 14] curl#35 - TCP connection reset by peer
[Errno 12] curl#35 - Timeout
推荐国内用户安装阿里云镜像
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@sail ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
更新 yum 软件包索引
这里官网建议我们更新 yum 软件包索引:
yum makecache fast
[root@sail ~]# yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 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 | 69 kB 00:00:00
Metadata Cache Created
安装 Docker
做完前面的准备工作,就可以开始安装 Docker 了
yum -y install docker-ce docker-ce-cli containerd.io
这里的
docker-ce
指的是 Docker 的社区版,如果是需要企业版的话就改为docker-ee
,不过企业版是收费的,而且功能也略有不同,官方更推荐社区版,所以这里我们安装docker-ce
。
[root@sail ~]# yum -y install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.12-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.12-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.11-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.11-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-20.10.11-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.11-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.11-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.119.2-1.911c772.el7_8.noarch
---> Package docker-ce-rootless-extras.x86_64 0:20.10.11-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.11-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.11-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.9.0-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-21.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-34.el7 will be installed
--> Processing Dependency: policycoreutils = 2.5-34.el7 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-34.el7.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.5-4.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.5-4.el7 for package: audit-libs-python-2.8.5-4.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package policycoreutils.x86_64 0:2.5-29.el7_6.1 will be updated
---> Package policycoreutils.x86_64 0:2.5-34.el7 will be an update
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.8.4-4.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.4-4.el7 for package: audit-2.8.4-4.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.5-4.el7 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.8.4-4.el7 will be updated
---> Package audit.x86_64 0:2.8.5-4.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================================================================================================
Installing:
containerd.io x86_64 1.4.12-3.1.el7 docker-ce-stable 28 M
docker-ce x86_64 3:20.10.11-3.el7 docker-ce-stable 23 M
docker-ce-cli x86_64 1:20.10.11-3.el7 docker-ce-stable 29 M
Installing for dependencies:
audit-libs-python x86_64 2.8.5-4.el7 base 76 k
checkpolicy x86_64 2.5-8.el7 base 295 k
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
docker-ce-rootless-extras x86_64 20.10.11-3.el7 docker-ce-stable 8.0 M
docker-scan-plugin x86_64 0.9.0-3.el7 docker-ce-stable 3.7 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
libcgroup x86_64 0.41-21.el7 base 66 k
libsemanage-python x86_64 2.5-14.el7 base 113 k
policycoreutils-python x86_64 2.5-34.el7 base 457 k
python-IPy noarch 0.75-6.el7 base 32 k
setools-libs x86_64 3.3.8-4.el7 base 620 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Updating for dependencies:
audit x86_64 2.8.5-4.el7 base 256 k
audit-libs x86_64 2.8.5-4.el7 base 102 k
policycoreutils x86_64 2.5-34.el7 base 917 k
Transaction Summary
==================================================================================================================================================================================================================================================================
Install 3 Packages (+13 Dependent packages)
Upgrade ( 3 Dependent packages)
Total download size: 95 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/19): audit-libs-2.8.5-4.el7.x86_64.rpm | 102 kB 00:00:00
(2/19): audit-2.8.5-4.el7.x86_64.rpm | 256 kB 00:00:00
(3/19): audit-libs-python-2.8.5-4.el7.x86_64.rpm | 76 kB 00:00:00
(4/19): checkpolicy-2.5-8.el7.x86_64.rpm | 295 kB 00:00:00
(5/19): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.11-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY===========- ] 11 MB/s | 38 MB 00:00:04 ETA
Public key for docker-ce-20.10.11-3.el7.x86_64.rpm is not installed
(6/19): docker-ce-20.10.11-3.el7.x86_64.rpm | 23 MB 00:00:02
(7/19): containerd.io-1.4.12-3.1.el7.x86_64.rpm | 28 MB 00:00:05
(8/19): docker-ce-rootless-extras-20.10.11-3.el7.x86_64.rpm | 8.0 MB 00:00:01
(9/19): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(10/19): libsemanage-python-2.5-14.el7.x86_64.rpm | 113 kB 00:00:00
(11/19): policycoreutils-2.5-34.el7.x86_64.rpm | 917 kB 00:00:00
(12/19): libcgroup-0.41-21.el7.x86_64.rpm | 66 kB 00:00:00
(13/19): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(14/19): policycoreutils-python-2.5-34.el7.x86_64.rpm | 457 kB 00:00:00
(15/19): python-IPy-0.75-6.el7.noarch.rpm | 32 kB 00:00:00
(16/19): setools-libs-3.3.8-4.el7.x86_64.rpm | 620 kB 00:00:00
(17/19): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(18/19): docker-scan-plugin-0.9.0-3.el7.x86_64.rpm | 3.7 MB 00:00:00
(19/19): docker-ce-cli-20.10.11-3.el7.x86_64.rpm | 29 MB 00:00:04
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 13 MB/s | 95 MB 00:00:07
Retrieving key from https://mirrors.aliyun.com/docker-ce/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://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : audit-libs-2.8.5-4.el7.x86_64 1/22
Updating : policycoreutils-2.5-34.el7.x86_64 2/22
Installing : libcgroup-0.41-21.el7.x86_64 3/22
Installing : audit-libs-python-2.8.5-4.el7.x86_64 4/22
Installing : 1:docker-ce-cli-20.10.11-3.el7.x86_64 5/22
Installing : docker-scan-plugin-0.9.0-3.el7.x86_64 6/22
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 7/22
Installing : libsemanage-python-2.5-14.el7.x86_64 8/22
Installing : fuse3-libs-3.6.1-4.el7.x86_64 9/22
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 10/22
Installing : setools-libs-3.3.8-4.el7.x86_64 11/22
Installing : python-IPy-0.75-6.el7.noarch 12/22
Installing : checkpolicy-2.5-8.el7.x86_64 13/22
Installing : policycoreutils-python-2.5-34.el7.x86_64 14/22
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 15/22
setsebool: SELinux is disabled.
Installing : containerd.io-1.4.12-3.1.el7.x86_64 16/22
Installing : 3:docker-ce-20.10.11-3.el7.x86_64 17/22
Installing : docker-ce-rootless-extras-20.10.11-3.el7.x86_64 18/22
Updating : audit-2.8.5-4.el7.x86_64 19/22
Cleanup : audit-2.8.4-4.el7.x86_64 20/22
Cleanup : policycoreutils-2.5-29.el7_6.1.x86_64 21/22
Cleanup : audit-libs-2.8.4-4.el7.x86_64 22/22
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 1/22
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 2/22
Verifying : docker-ce-rootless-extras-20.10.11-3.el7.x86_64 3/22
Verifying : audit-libs-2.8.5-4.el7.x86_64 4/22
Verifying : checkpolicy-2.5-8.el7.x86_64 5/22
Verifying : policycoreutils-2.5-34.el7.x86_64 6/22
Verifying : python-IPy-0.75-6.el7.noarch 7/22
Verifying : policycoreutils-python-2.5-34.el7.x86_64 8/22
Verifying : setools-libs-3.3.8-4.el7.x86_64 9/22
Verifying : docker-scan-plugin-0.9.0-3.el7.x86_64 10/22
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 11/22
Verifying : audit-2.8.5-4.el7.x86_64 12/22
Verifying : libsemanage-python-2.5-14.el7.x86_64 13/22
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 14/22
Verifying : 3:docker-ce-20.10.11-3.el7.x86_64 15/22
Verifying : audit-libs-python-2.8.5-4.el7.x86_64 16/22
Verifying : containerd.io-1.4.12-3.1.el7.x86_64 17/22
Verifying : 1:docker-ce-cli-20.10.11-3.el7.x86_64 18/22
Verifying : libcgroup-0.41-21.el7.x86_64 19/22
Verifying : policycoreutils-2.5-29.el7_6.1.x86_64 20/22
Verifying : audit-libs-2.8.4-4.el7.x86_64 21/22
Verifying : audit-2.8.4-4.el7.x86_64 22/22
Installed:
containerd.io.x86_64 0:1.4.12-3.1.el7 docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-cli.x86_64 1:20.10.11-3.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-ce-rootless-extras.x86_64 0:20.10.11-3.el7 docker-scan-plugin.x86_64 0:0.9.0-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8
fuse3-libs.x86_64 0:3.6.1-4.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
slirp4netns.x86_64 0:0.4.3-4.el7_8
Dependency Updated:
audit.x86_64 0:2.8.5-4.el7 audit-libs.x86_64 0:2.8.5-4.el7 policycoreutils.x86_64 0:2.5-34.el7
Complete!
启动 Docker
Docker 安装完成后,就可以运行如下命令启动。
systemctl start docker
[root@sail ~]# systemctl start docker
[root@sail ~]#
测试
启动 Docker 后,我们可以运行如下命令对 Docker 进行测试。
- 查看 Docker 进程。
[root@sail ~]# ps -ef|grep docker
root 18805 1 0 16:54 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
root 19233 16612 0 16:59 pts/0 00:00:00 grep --color=auto docker
由此可以看出,Docker 是启动成功了的。
- 查看版本信息。
[root@sail ~]# 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:38:53 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:37:17 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.12
GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
可以看出 Docker 的版本为 20.10.11。
- 运行 Hello World 镜像。
Hello World 镜像是 Docker 官方为测试 Docker 环境和运行情况所设定的一个程序。
docker run hello-world
[root@sail ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:cc15c5b292d8525effc0f89cb299f1804f3a725c8d05e158653a563f15e4f685
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 工作环境是搭建完毕了的。
Hello from Docker!
This message shows that your installation appears to be working correctly.
- 查看镜像。
在执行启动 Hello World 镜像的命令时,如果本地没有该镜像,会先从镜像库中拉取该镜像再启动。
使用
docker images
查看目前的 Docker 的镜像情况:
[root@sail ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 2 months ago 13.3kB
这里我们可以看到刚拉取的 hello-world 镜像,以及它的相关信息。
阿里云镜像加速
如果是阿里云的服务器,还可以使用阿里云的镜像加速使得 Docker 使用起来更加快速和高效。
- 打开阿里云服务器列表,选择如图所示的容器镜像服务。
- 选择如图所示的镜像加速器,然后选择对应的服务器系统。
- 在服务器上依次执行上图所示的4条命令即可实现阿里云的镜像加速。
至此,yum 方式安装 Docker 完毕。