目录
3、Loading mirror speeds from cached hostfile 解决方案
一、Docker版本
Docker 有两个版本:社区版(Community Edition,缩写为 CE)、企业版(Enterprise Edition,缩写为 EE)下面的安装都是社区版。
二、一键安装docker及docker-compose
1、新建docker-install.sh
将以下内容直接copy到docker-install.sh
#!/bin/bash
# shellcheck disable=SC2046
BASE_PATH=$(cd `dirname $0`;pwd)
echo "当前系统版本:";sudo cat /etc/redhat-release;
echo -e "\033[46;37;5m -------------- 开始安装docker所需环境 -------------- \033[0m";
# 安装docker环境
echo " ------------ 开始安装docker服务 ------------ ";
yum update -y;
yum install -y yum-utils device-mapper-persistent-data lvm2;
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo;
yum install -y docker-ce;
systemctl start docker;
systemctl enable docker;
docker version;
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose;
sudo chmod +x /usr/local/bin/docker-compose;
docker-compose version;
echo " ------------ docker服务安装完毕 ------------ ";
2、授权并运行
chmod 777 docker-install.sh
sh docker-install.sh
三、选择具体版本安装步骤详解
0、切换root
sudo -s
1、更新新yum源
yum -y update
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
github_git-lfs/x86_64/signature | 833 B 00:00:00
github_git-lfs/x86_64/signature | 1.8 kB 00:00:00 !!!
github_git-lfs-source/signature | 833 B 00:00:00
github_git-lfs-source/signature | 1.8 kB 00:00:00 !!!
Resolving Dependencies
--> Running transaction check
---> Package at.x86_64 0:3.1.13-24.el7 will be updated
---> Package at.x86_64 0:3.1.13-25.el7_9 will be an update
---> Package bash.x86_64 0:4.2.46-34.el7 will be updated
.........................................................................................
Complete!
2、yum-utils安装
yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
Nothing to do
3、Loading mirror speeds from cached hostfile 解决方案
确保服务能连接网络才能执行以下wget命令
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum makecache fast
yum install -y yum-utils
[root@]# yum install -y yum-utils
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
github_git-lfs/x86_64/signature | 833 B 00:00:00
github_git-lfs/x86_64/signature | 1.8 kB 00:00:00 !!!
github_git-lfs-source/signature | 833 B 00:00:00
github_git-lfs-source/signature | 1.8 kB 00:00:00 !!!
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
4、查看仓库中所有docker版本,并选择新版本安装
yum list docker-ce --showduplicates | sort -r
* updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks, versionlock
* extras: mirrors.aliyun.com
docker-ce.x86_64 3:20.10.9-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.8-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.7-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.6-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.5-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.4-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.2-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.21-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.20-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.19-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.18-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.17-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.16-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.15-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.14-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.13-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.12-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.11-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.10-3.el7 docker-ce-stable
docker-ce.x86_64 3:20.10.0-3.el7 docker-ce-stable
.............................................................
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
* base: mirrors.aliyun.com
Available Packages
我选择安装的版本是 3:20.10.21-3.el7版本
yum install -y docker-ce-3:20.10.21-3.el7.x86_64
Loaded plugins: fastestmirror, langpacks, versionlock
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 3:20.10.21-3.el7 will be installed
.....................................
Installed:
docker-ce.x86_64 3:20.10.21-3.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 containerd.io.x86_64 0:1.6.10-3.1.el7 docker-ce-cli.x86_64 1:20.10.21-3.el7 docker-ce-rootless-extras.x86_64 0:20.10.21-3.el7
docker-scan-plugin.x86_64 0:0.21.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!
5、启动docker
systemctl start docker
6、docker ps验证
[root@dev-001 yum.repos.d]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7、设置开机自动启动
systemctl enable docker