Docker 从零开始学习-安装Docker
安装必要的系统工具
[root@k8sdocker01 beef]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Package device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 already installed and latest version
Package 7:lvm2-2.02.187-6.el7_9.5.x86_64 already installed and latest version
Nothing to do
[root@k8sdocker01 beef]#
[root@k8sdocker01 beef]#
配置添加docker软件源
[root@k8sdocker01 beef]# yum-config-manager –add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file https://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
[root@k8sdocker01 beef]# sed -i ‘s+download.docker.com+mirrors.aliyun.com/docker-ce+’ /etc/yum.repos.d/docker-ce.repo
[root@k8sdocker01 beef]#
更新并安装Docker-CE
[root@k8sdocker01 beef]# yum makecache fast
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Metadata Cache Created
[root@k8sdocker01 beef]# sudo yum -y install docker-ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
–> Running transaction check
—> Package docker-ce.x86_64 3:20.10.8-3.el7 will be installed
–> Processing Dependency: container-selinux >= 2:2.74 for package: 3:docker-ce-20.10.8-3.el7.x86_64
–> Processing Dependency: containerd.io >= 1.4.1 for package: 3:docker-ce-20.10.8-3.el7.x86_64
–> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.8-3.el7.x86_64
–> Running transaction check
—> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
—> Package containerd.io.x86_64 0:1.4.9-3.1.el7 will be installed
—> Package docker-ce-rootless-extras.x86_64 0:20.10.8-3.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================================================
Installing:
docker-ce x86_64 3:20.10.8-3.el7 docker-ce-stable 23 M
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
containerd.io x86_64 1.4.9-3.1.el7 docker-ce-stable 30 M
docker-ce-rootless-extras x86_64 20.10.8-3.el7 docker-ce-stable 8.0 M
Transaction Summary
====================================================================================================================================================================
Install 1 Package (+3 Dependent packages)
Total download size: 61 M
Installed size: 227 M
Downloading packages:
(1/4): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
(2/4): docker-ce-20.10.8-3.el7.x86_64.rpm | 23 MB 00:00:24
(3/4): docker-ce-rootless-extras-20.10.8-3.el7.x86_64.rpm | 8.0 MB 00:00:11
(4/4): containerd.io-1.4.9-3.1.el7.x86_64.rpm | 30 MB 00:00:42
——————————————————————————————————————————————————————–
Total 1.4 MB/s | 61 MB 00:00:42
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 1/4
Installing : containerd.io-1.4.9-3.1.el7.x86_64 2/4
Installing : docker-ce-rootless-extras-20.10.8-3.el7.x86_64 3/4
Installing : 3:docker-ce-20.10.8-3.el7.x86_64 4/4
Verifying : containerd.io-1.4.9-3.1.el7.x86_64 1/4
Verifying : 3:docker-ce-20.10.8-3.el7.x86_64 2/4
Verifying : docker-ce-rootless-extras-20.10.8-3.el7.x86_64 3/4
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 4/4
Installed:
docker-ce.x86_64 3:20.10.8-3.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.4.9-3.1.el7 docker-ce-rootless-extras.x86_64 0:20.10.8-3.el7
Complete!
[root@k8sdocker01 beef]#
开启Docker服务并验证
[root@k8sdocker01 beef]# service docker start
Redirecting to /bin/systemctl start docker.service
[root@k8sdocker01 beef]# docker version
Client: Docker Engine – Community
Version: 20.10.8
API version: 1.41
Go version: go1.16.6
Git commit: 3967b7d
Built: Fri Jul 30 19:55:49 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine – Community
Engine:
Version: 20.10.8
API version: 1.41 (minimum version 1.12)
Go version: go1.16.6
Git commit: 75249d8
Built: Fri Jul 30 19:54:13 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.9
GitCommit: e25210fe30a0a703442421b0f60afac609f950a3
runc:
Version: 1.0.1
GitCommit: v1.0.1-0-g4144b63
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@k8sdocker01 beef]#