1、安装依赖
yum -y install yum-utils
2、指定Docker安装源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3、安装Docker
yum -y install docker-ce
4、设置阿里云镜像加速
vi /etc/docker/daemon.json
添加以下内容
{
"registry-mirrors": [
"https://9cpn8tt6.mirror.aliyuncs.com"
]
}
5、常用命令
systemctl enable docker
systemctl start docker
systemctl restart docker
systemctl stop docker
systemctl status docker
5、安装Docker-compose
- 下载二进制文件
wget https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64
- 移动文件
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
- 赋予可执行权限
chmod +x /usr/local/bin/docker-compose
- 创建软链
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
- 测试是否安装成功
docker-compose --version