Centos7 installs docker and configures mirroring

1. Configure ali's yum mirror source

1. Obtain Alibaba Cloud repo

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

#下面两条命令如果执行报错可以直接跳过执行2
cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bak

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2. Clean up the original cache and re-cache

yum clean all

yum makecache

3.1 Uninstall the old version of docker

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
                  
#若之前没有安装过docker,会提示一堆不匹配,是正常现象,直接往下执行就好

3.2 Download the required installation package

yum install -y yum-utils

3.3 Setting up the mirror warehouse

# 设置阿里云的Docker镜像仓库
yum-config-manager \
    --add-repo \
    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 

3.4 Update the yum package index

yum makecache fast

3.5 Install docker related configuration

 yum install docker-ce docker-ce-cli containerd.io

4. Start docker

systemctl start docker
# 查看当前版本号,是否启动成功
docker version
# 设置开机自启动
systemctl enable docker

5.run hello-world

docker run hello-world

Guess you like

Origin blog.csdn.net/weixin_48244108/article/details/126838493