安装所需的软件包。yum-utils 提供了 yum-config-manager ,并且 device mapper 存储驱动程序需要 device-mapper-persistent-data 和 lvm2。
[root@localhost yum.repos.d]# yum install -y yum-utils \
> device-mapper-persistent-data \
> lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.bfsu.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
* webtatic: us-east.repo.webtatic.com
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
webtatic | 3.6 kB 00:00
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-1.el7 will be updated
---> Package device-mapper-persistent-data.x86_64 0:0.8.5-3.el7_9.2 will be an update
---> Package lvm2.x86_64 7:2.02.185-2.el7 will be updated
---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be an update
--> 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
--> Running transaction check
---> Package lvm2-libs.x86_64 7:2.02.185-2.el7 will be updated
---> Package lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 will be an update
--> 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
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
--> 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
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.158-2.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.158-2.el7 for package: 7:device-mapper-libs-1.02.158-2.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.158-2.el7 will be updated
---> Package device-mapper-event-libs.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.158-2.el7 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
================================================================================
Updating:
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
Updating for dependencies:
device-mapper x86_64 7:1.02.170-6.el7_9.5 updates 297 k
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
device-mapper-libs x86_64 7:1.02.170-6.el7_9.5 updates 325 k
lvm2-libs x86_64 7:2.02.187-6.el7_9.5 updates 1.1 M
Transaction Summary
================================================================================
Upgrade 2 Packages (+5 Dependent packages)
Total size: 3.8 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 1/14
Updating : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 2/14
Updating : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 3/14
Updating : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 4/14
Updating : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 5/14
Updating : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 6/14
Updating : 7:lvm2-2.02.187-6.el7_9.5.x86_64 7/14
Cleanup : 7:lvm2-2.02.185-2.el7.x86_64 8/14
Cleanup : 7:lvm2-libs-2.02.185-2.el7.x86_64 9/14
Cleanup : 7:device-mapper-event-1.02.158-2.el7.x86_64 10/14
Cleanup : 7:device-mapper-event-libs-1.02.158-2.el7.x86_64 11/14
Cleanup : 7:device-mapper-1.02.158-2.el7.x86_64 12/14
Cleanup : 7:device-mapper-libs-1.02.158-2.el7.x86_64 13/14
Cleanup : device-mapper-persistent-data-0.8.5-1.el7.x86_64 14/14
Verifying : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 1/14
Verifying : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 2/14
Verifying : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 3/14
Verifying : device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 4/14
Verifying : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 5/14
Verifying : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 6/14
Verifying : 7:lvm2-2.02.187-6.el7_9.5.x86_64 7/14
Verifying : 7:device-mapper-event-1.02.158-2.el7.x86_64 8/14
Verifying : device-mapper-persistent-data-0.8.5-1.el7.x86_64 9/14
Verifying : 7:device-mapper-event-libs-1.02.158-2.el7.x86_64 10/14
Verifying : 7:device-mapper-1.02.158-2.el7.x86_64 11/14
Verifying : 7:device-mapper-libs-1.02.158-2.el7.x86_64 12/14
Verifying : 7:lvm2-libs-2.02.185-2.el7.x86_64 13/14
Verifying : 7:lvm2-2.02.185-2.el7.x86_64 14/14
Updated:
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
Dependency Updated:
device-mapper.x86_64 7:1.02.170-6.el7_9.5
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
device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5
lvm2-libs.x86_64 7:2.02.187-6.el7_9.5
Complete!
添加仓库
[root@localhost yum.repos.d]# yum-config-manager \
> --add-repo \
> https://download.docker.com/linux/centos/docker-ce.repo
Loaded plugins: 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
[root@localhost yum.repos.d]#
安装
[root@localhost yum.repos.d]# yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
* webtatic: us-east.repo.webtatic.com
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.5.11-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.5.11-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.14-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.14-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.14-3.el7 will be installed
--> Processing Dependency: docker-scan-plugin(x86-64) for package: 1:docker-ce-cli-20.10.14-3.el7.x86_64
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package docker-ce-rootless-extras.x86_64 0:20.10.14-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.14-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.14-3.el7.x86_64
---> Package docker-scan-plugin.x86_64 0:0.17.0-3.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 slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
containerd.io x86_64 1.5.11-3.1.el7 docker-ce-stable 29 M
docker-ce x86_64 3:20.10.14-3.el7 docker-ce-stable 22 M
docker-ce-cli x86_64 1:20.10.14-3.el7 docker-ce-stable 30 M
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
docker-ce-rootless-extras
x86_64 20.10.14-3.el7 docker-ce-stable 8.1 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.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
Transaction Summary
================================================================================
Install 3 Packages (+6 Dependent packages)
Total download size: 94 M
Installed size: 378 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for extras
(1/9): container-selinux-2.119.2-1.911c772.el7_8.noarch.rp | 40 kB 00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.14-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-20.10.14-3.el7.x86_64.rpm is not installed
(2/9): docker-ce-20.10.14-3.el7.x86_64.rpm | 22 MB 00:02
(3/9): containerd.io-1.5.11-3.1.el7.x86_64.rpm | 29 MB 00:03
(4/9): docker-ce-cli-20.10.14-3.el7.x86_64.rpm | 30 MB 00:01
(5/9): docker-ce-rootless-extras-20.10.14-3.el7.x86_64.rpm | 8.1 MB 00:00
(6/9): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00
(7/9): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00
(8/9): docker-scan-plugin-0.17.0-3.el7.x86_64.rpm | 3.7 MB 00:00
(9/9): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00
--------------------------------------------------------------------------------
Total 22 MB/s | 94 MB 00:04
Retrieving key from https://download.docker.com/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://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : docker-scan-plugin-0.17.0-3.el7.x86_64 1/9
Installing : 1:docker-ce-cli-20.10.14-3.el7.x86_64 2/9
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 3/9
Installing : containerd.io-1.5.11-3.1.el7.x86_64 4/9
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 5/9
Installing : fuse3-libs-3.6.1-4.el7.x86_64 6/9
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 7/9
Installing : docker-ce-rootless-extras-20.10.14-3.el7.x86_64 8/9
Installing : 3:docker-ce-20.10.14-3.el7.x86_64 9/9
Verifying : 3:docker-ce-20.10.14-3.el7.x86_64 1/9
Verifying : containerd.io-1.5.11-3.1.el7.x86_64 2/9
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 3/9
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 4/9
Verifying : docker-ce-rootless-extras-20.10.14-3.el7.x86_64 5/9
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 6/9
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 7/9
Verifying : 1:docker-ce-cli-20.10.14-3.el7.x86_64 8/9
Verifying : docker-scan-plugin-0.17.0-3.el7.x86_64 9/9
Installed:
containerd.io.x86_64 0:1.5.11-3.1.el7 docker-ce.x86_64 3:20.10.14-3.el7
docker-ce-cli.x86_64 1:20.10.14-3.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8
docker-ce-rootless-extras.x86_64 0:20.10.14-3.el7
docker-scan-plugin.x86_64 0:0.17.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
Complete!
启动,查看版本
[root@localhost yum.repos.d]# systemctl start docker
[root@localhost yum.repos.d]# docker version
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:49:57 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.14
API version: 1.41 (minimum version 1.12)
Go version: go1.16.15
Git commit: 87a90dc
Built: Thu Mar 24 01:48:24 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.11
GitCommit: 3df54a852345ae127d1fa3092b95168e4a88e2f8
runc:
Version: 1.0.3
GitCommit: v1.0.3-0-gf46b6ba
docker-init:
Version: 0.19.0
GitCommit: de40ad0
验证
[root@localhost yum.repos.d]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:bfea6278a0a267fad2634554f4f0c6f31981eea41c553fdf5a83e95a41d40c38
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/