安装前提条件
Docker 要求 CentOS 系统的内核版本高于 3.10 ,首先验证你的服务器是否支持Docker!
通过 uname -r
命令查看当前的内核版本
`[root@localhost home]# uname -r
3.10.0-1160.el7.x86_64`
可以看到我的服务器是4.18.0,是支持Docker的。
第一步:检查并清除系统残余项,并安装Docker依赖环境
1、清除残余
`[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine`
执行结果
`No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-selinux
No match for argument: docker-engine-selinux
No match for argument: docker-engine
没有软件包需要移除。
依赖关系解决。
无需任何处理。
完毕!`
安装下载Docker依赖的工具
`[root@localhost home~]# yum install -y yum-utils device-mapper-persistent-data lvm2`
结果
`已升级:
device-mapper-8:1.02.177-10.el8.x86_64 device-mapper-event-8:1.02.177-10.el8.x86_64
device-mapper-event-libs-8:1.02.177-10.el8.x86_64 device-mapper-libs-8:1.02.177-10.el8.x86_64
device-mapper-persistent-data-0.9.0-4.el8.x86_64 dnf-4.7.0-4.el8.noarch
dnf-data-4.7.0-4.el8.noarch dnf-plugins-core-4.0.21-3.el8.noarch
ima-evm-utils-1.3.2-12.el8.x86_64 libdnf-0.63.0-3.el8.x86_64
librepo-1.14.0-2.el8.x86_64 libsolv-0.7.19-1.el8.x86_64
lvm2-8:2.03.12-10.el8.x86_64 lvm2-libs-8:2.03.12-10.el8.x86_64
python3-dnf-4.7.0-4.el8.noarch python3-dnf-plugins-core-4.0.21-3.el8.noarch
python3-hawkey-0.63.0-3.el8.x86_64 python3-libdnf-0.63.0-3.el8.x86_64
python3-librepo-1.14.0-2.el8.x86_64 python3-rpm-4.14.3-19.el8.x86_64
rpm-4.14.3-19.el8.x86_64 rpm-build-libs-4.14.3-19.el8.x86_64
rpm-libs-4.14.3-19.el8.x86_64 rpm-plugin-selinux-4.14.3-19.el8.x86_64
rpm-plugin-systemd-inhibit-4.14.3-19.el8.x86_64 yum-4.7.0-4.el8.noarch
已安装:
libmodulemd-2.13.0-1.el8.x86_64 tpm2-tss-2.3.2-4.el8.x86_64 yum-utils-4.0.21-3.el8.noarch
完毕!`
添加阿里云的软件源
`[root@localhost home]# 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`
以后每个软件都优先从阿里云的软件库中下载,如果阿里云仓库没有,会去docker.hub中下载。(与maven仓库同理)
更新yum缓存(为了保证能更新和下载需要的服务:如docker)
`[root@iZbp18425116ezmjdmbdgeZ ~]# sudo yum makecache`
结果:
`[root@iZbp18425116ezmjdmbdgeZ ~]
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-epel.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
CentOS-8 - AppStream 441 kB/s | 4.3 kB 00:00
CentOS-8 - Base 437 kB/s | 3.9 kB 00:00
CentOS-8 - Extras 194 kB/s | 1.5 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 602 kB/s | 4.7 kB 00:00
Docker CE Stable - x86_64 30 kB/s | 19 kB 00:00
元数据缓存已建立。`
第二步:Docker依赖环境搭建好之后,安装并启动Docker
1、安装Docker(CE-社区版)
`[root@localhost home]# sudo yum -y install docker-ce`
由于需要下载并安装docker,有的机器会有点慢,请耐心等待!
结果:
`Installed:
docker-ce.x86_64 3:18.09.0-3.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.1-3.el7_5.1 checkpolicy.x86_64 0:2.5-6.el7 container-selinux.noarch 2:2.68-1.el7
containerd.io.x86_64 0:1.2.0-3.el7 docker-ce-cli.x86_64 1:18.09.0-3.el7 libcgroup.x86_64 0:0.41-15.el7
libseccomp.x86_64 0:2.3.1-3.el7 libsemanage-python.x86_64 0:2.5-11.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3
policycoreutils-python.x86_64 0:2.5-22.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-2.el7
Dependency Updated:
audit.x86_64 0:2.8.1-3.el7_5.1 audit-libs.x86_64 0:2.8.1-3.el7_5.1 libselinux.x86_64 0:2.5-12.el7
libselinux-python.x86_64 0:2.5-12.el7 libselinux-utils.x86_64 0:2.5-12.el7 libsemanage.x86_64 0:2.5-11.el7
libsepol.x86_64 0:2.5-8.1.el7 policycoreutils.x86_64 0:2.5-22.el7 selinux-policy.noarch 0:3.13.1-192.el7_5.6
selinux-policy-targeted.noarch 0:3.13.1-192.el7_5.6
Complete!`
看到complete!下载并安装成功!
2、启动Docker服务
`[root@localhost home]# systemctl start docker`
以上我们已经将Docker安装好了,接下来测试下Docker是否可以顺利启动:
`[root@localhost home]# docker info`
结果:
`Client: Docker Engine - Community
Version: 26.1.3
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.14.0
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.27.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 26.1.3
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e377cd56a71523140ca6ae87e30244719194a521
runc version: v1.1.12-0-g51d5e94
init version: de40ad0
Security Options:
seccomp
Profile: builtin
Kernel Version: 3.10.0-1160.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.49GiB
Name: localhost.localdomain
ID: ca842e60-2eac-46f3-ba33-d4724a40cf11
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
我们可以看到Docker已经启动成功,而且容器与镜像数都为0,是一个全新的docker服务
3、设置开机自启(非必设项,根据自己习惯设置)
`[root@iZx4xwfjh1zsdsZ /] systemctl enable docker
结果
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
到此为止,Docker就已经下载并安装完成!
查看docker版本
`[root@localhost home]# docker -v
Docker version 20.10.11, build dea9396`
移除Docker-ce服务
`yum remove docker-ce`
删除Docker依赖项
`rm -rf /var/lib/docker`
标签:容器,x86,el8,64,linux,docker,Docker,el7
From: https://www.cnblogs.com/fylh/p/18197625