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

(3) Generate cache

yum makecache

(4) Eliminate possible alarms

sed -i -e '/' -e '/' /etc/yum.repos.d/CentOS-Base.repo

Excerpt from above

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

(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": [""]
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`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/
logfile /var/log/ntp.log
restrict    default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
fudge stratum 10
server iburst minpoll 4 maxpoll 10
restrict nomodify notrap nopeer noquery

Posted by xiao on Thu, 04 Jun 2020 10:16:51 -0700