近期,须要在CentOS 7上安装dokcer环境,特记录下如何基于阿里云代理实现。linux
(1)备份原镜像git
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
(2) 下载新的CentOS-Base.repogithub
#仅针对CentOS7 wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
(3) 生成缓存docker
yum makecache
(4)消除可能的告警json
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
以上内容摘抄自https://developer.aliyun.com/mirror/centoscentos
(1)安装必要工具缓存
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
(2)添加软件源信息bash
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
(3)更新yum缓存app
sudo yum makecache fast
(4)安装docker运维
sudo yum -y install docker-ce
(5)启动docker后台服务
sudo systemctl start docker sudo systemctl enable docker
(6) 配置阿里云镜像加速器
# 不设置,镜像的下载速度实在是堪忧 sudo mkdir -p /etc/docker # 注意,配置的网址能够更换为本身的配置,登陆阿里云在控制台中寻找镜像加速器 sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://s3w3uu4l.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
(7)基于DAOCLOUD安装docker-compose
# 最近github很不稳定,仍是使用daocloud完成安装 curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
若是运维未给你设置NTP服务,那么就本身动手,避免给之后挖坑。
# 编辑/etc/ntp.conf文件,设置以下内容 driftfile /var/lib/ntp/drift pidfile /var/run/ntpd.pid logfile /var/log/ntp.log restrict default kod nomodify notrap nopeer noquery restrict -6 default kod nomodify notrap nopeer noquery restrict 127.0.0.1 server 127.127.1.0 fudge 127.127.1.0 stratum 10 server ntp.aliyun.com iburst minpoll 4 maxpoll 10 restrict ntp.aliyun.com nomodify notrap nopeer noquery