Install Dokcer and set NTP based on alicloud agent

Keywords: Linux Docker yum CentOS sudo

Recently, you need to install the dokcer environment on CentOS 7, recording how to implement it based on Alibaba cloud agent.

1. Replace CentOS image

(1) Back up the original image

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

(2) Download new CentOS-Base.repo

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

(3) Generate cache

yum makecache

(4) Eliminate possible alarms

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

Excerpt from above https://developer.aliyun.com/mirror/centos

2. Install docker and docker compose

(1) Installation of necessary tools

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

(2) Add software source information

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

(3) Update yum cache

sudo yum makecache fast

(4) Install docker

sudo yum -y install docker-ce

(5) Start docker background service

sudo systemctl start docker
sudo systemctl enable docker

(6) Configure alicloud image accelerator

# No setting, the download speed of the image is really worrying
sudo mkdir -p /etc/docker
# Note that the configured URL can be changed to its own configuration. Log in to alicloud and search for the image accelerator in the console
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://s3w3uu4l.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

(7) Installing docker compose based on DAOCLOUD

# Recently, github is unstable. Do you want to use daocloud to complete the installation
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

Set up NTP synchronization

If the operation and maintenance department doesn't set up NTP service for you, do it by yourself to avoid digging holes in the future.

# Edit / etc/ntp.conf File, set as follows
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 by xiao on Thu, 04 Jun 2020 10:16:51 -0700