1.检查安装的Linux版本:
[root@localhost /]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
2.yum安装gcc相关:
#-y: 安装过程中的提升默认选yes
yum -y install gcc
yum -y install gcc-c++
3.卸载系统中已经安装的Docker版本:
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
#使用阿里云镜像下载解决报错问题:
yum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.更新yum软件包索引:
yum makecache fast
##安装Docker Engine #containerd.io
yum install docker-ce docker-ce-cli
5.启动Docker:
#没有报错,docker启动成功
systemctl start docker
#设置开机启动
systemctl enable docker
6.测试Docker是否安装成功:
#看到docker进程
ps -ef|grep docker
#查看版本信息
docker version
#看到运行的镜像
docker images
7.修改国内的镜像地址
cat << EOF > /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.1panel.live/",
"https://docker.anyhub.us.kg",
"https://docker.anyhub.us.kg",
"https://dockerhub.icu"
],
"exec-opts":["native.cgroupdriver=systemd"]
}
EOF
systemctl daemon-reload
systemctl restart docker
网易:http://hub-mirror.c.163.com
中科大镜像地址:http://mirrors.ustc.edu.cn/
中科大github地址:https://github.com/ustclug/mirrorrequest
Azure中国镜像地址:http://mirror.azure.cn/
Azure中国github地址:https://github.com/Azure/container-service-for-azure-china
DockerHub镜像仓库: https://hub.docker.com/
阿里云镜像仓库: https://cr.console.aliyun.com
google镜像仓库: https://console.cloud.google.com/gcr/images/google-containers/GLOBAL (如果你本地可以翻墙的话是可以连上去的 )
coreos镜像仓库: https://quay.io/repository/
RedHat镜像仓库: https://access.redhat.com/containers
8.安装docker-compose
mkdir /opt/docker
cd /opt/docker
wget https://mirrors.aliyun.com/docker-toolbox/linux/compose/1.21.2/docker-compose-Linux-x86_64
cp -p docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -v