Ali cloud server CentOS 7.6 install docker and docker-compose
Preface: Docker requires the CentOS system to have a kernel version higher than 3.10, check the prerequisites on this page to verify whether your CentOS version supports Docker
Check your current kernel version with the uname -r command
uname -r
1. docker installation
1.1 Uninstall the old version
yum remove docker docker-common docker-selinux docker-engine
1.2 Install the required software packages
yum install -y yum-utils device-mapper-persistent-data lvm2
1.3 Set yum source
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1.4 install docker
yum install docker-ce
1.5 start docker
systemctl start docker
1.6 Verify that the installation was successful
docker version
# 开机启动docker服务
systemctl enable docker
# 重启docker
systemctl restart docker
# 关闭docker
systemctl stop docker
Two, docker-compose installation
To install docker compose, you must first install docker
2.1 Download from official sources (download from foreign sources is relatively slow) or download from domestic sources
#Foreign source
curl -L “https://github.com/docker/compose/releases/download/v2.11.2/docker-compose- ( u n a m e − s ) − (uname -s)- ( u name e−s)−(uname -m)” -o /usr/local/bin/docker-compose
#domestic source
curl -SL https://get.daocloud.io/docker/compose/releases/download/v2.11.2/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
2.2 Corresponding file directory authorization
chmod +x /usr/local/bin/docker-compose
2.3 Create a soft connection
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
2.3 Check whether docker-compose is successfully installed
docker-compose --version
# 卸载docker compose
rm /usr/local/bin/docker-compose