基于阿里云代理安装Dokcer,设置NTP

近期,需要在CentOS 7上安装dokcer环境,特记录下如何基于阿里云代理实现。

1.更换CentoOS镜像

(1)备份原镜像

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

(2) 下载新的CentOS-Base.repo

#仅针对CentOS7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

(3) 生成缓存

yum makecache

(4)消除可能的告警

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/centos

2.安装docker以及docker-compose

(1)安装必要工具

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

(2)添加软件源信息

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

(3)更新yum缓存

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同步

如果运维未给你设置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
posted @ 2020-06-04 21:36  从此寂静无声  阅读(455)  评论(0编辑  收藏  举报