安装 yum-utils,用来管理yum源
bash
yum install -y yum-utils
配置阿里docker镜像
bash
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
更新
bash
yum makecache fast
安装docker-ce
bash
yum install -y docker-ce
启动并设置开机自启动
bash
sudo systemctl start docker
sudo systemctl enable docker
验证安装是否成功
bash
docker --version
docker info
安装docker-compose插件
bash
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
插件软连接方便实用可选
bash
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
验证
bash
docker-compose --version