yum安装docker

  1. 设置yum阿里源 官方文档:https://developer.aliyun.com/mirror/centos
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.`date +%Y%m%d`
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
yum makecache
  1. 安装docker 官方文档:https://docs.docker.com/engine/install/centos/
yum -y install yum-utils
# 官方源或阿里源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
docker -v
service docker start
  1. 安装docker命令补全
yum install -y bash-completion
  1. 配置docker境像加速器
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
 "registry-mirrors": ["https://7kk6lyrw.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
  1. 设置docker compose 官方文档:https://docs.docker.com/compose/install/
# 如果GitHub访问过慢,可使用国内镜像源
# curl -L "https://get.daocloud.io/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.29.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose
docker-compose -v