基於阿里雲代理安裝Dokcer,設置NTP

近期,須要在CentOS 7上安裝dokcer環境,特記錄下如何基於阿里雲代理實現。linux

1.更換CentoOS鏡像

(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

2.安裝docker以及docker-compose

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

若是運維未給你設置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
相關文章
相關標籤/搜索