docker的安装
CentOS 系统安装docker服务
CentOS 系统卸载docker服务
[root@10-13 backup]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
我们这里CentOS系统,直接参考官方文档关于docker在CentOS系统上的安装:
https://docs.docker.com/engine/install/centos/
系统要求:
To install Docker Engine, you need a maintained version of CentOS 7 or 8. Archived versions aren’t supported or tested.
CentOS 7 或者8,说的很清楚了
Uninstall old versions
删除旧的版本,源文档是有sudo的,这里直接登录root用户操作的,去掉sudo ,直接执行yum命令
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
Installation methods
安装方法
You can install Docker Engine in different ways, depending on your needs:
1)设置docker仓库,从Docker参考安装(也就是从yum源安装)
Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach.
2)下载RPM安装包手动安装
Some users download the RPM package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.
3)采用自动脚本安装
In testing and development environments, some users choose to use automated convenience scripts to install Docker.
我们采用第一种方法安装
1)
yum install -y yum-utils
CentOS-8 - PowerTools 93 B/s | 38 B 00:00
Error: Failed to download metadata for repo ‘PowerTools’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
报错,上网查,得知原因
CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到https://vault.centos.org
[root@10-13- backup]# sed -i -e “s|mirrorlist=|#mirrorlist=|g” /etc/yum.repos.d/CentOS-*
[root@10-134 backup]#
[root@10-13- backup]#
[root@10-14 backup]# sed -i -e “s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g” /etc/yum.repos.d/CentOS-*
[root@10-13-53-194 backup]#
再次运行,yum install -y yum-utils,可以了
2)Set up the repository
Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository.
安装yum工具和设置稳定的仓库
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
这里如果担心设置国外的地址,真正使用的时候,下载远程包报timeout 的话,可以改成国内的地址,比如阿里云的
yum-config-manager
–add-repo
https://mirrors.aliyum.com/docker-ce/linux/centos/docker-ce.repo
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
这里可以做一步,重建yum索引,这样以后安装组件速度会快点
yum makecache
CentOS-8 - AppStream 256 kB/s | 4.3 kB 00:00
CentOS-8 - Base 236 kB/s | 3.9 kB 00:00
CentOS-8 - Extras 106 kB/s | 1.5 kB 00:00
CentOS-8 - PowerTools 3.2 kB/s | 4.3 kB 00:01
CentOS-8 - Plus 106 kB/s | 1.5 kB 00:00
Docker CE Stable - x86_64 215 B/s | 3.5 kB 00:16
Extra Packages for Enterprise Linux