0. 前提条件
已安装Docker,若未安装,则参考 Centos7 安装 Docker
1. 下载(使用国内地址下载)
curl https://get.daocloud.io/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
注:写此文章时,版本号是1.29.2,随时间推移会有更新版本,也可以下载历史版本,修改命令链接中的1.29.2版本号即可
2. 授权
[root@localhost ~]# cd /usr/local/bin [root@localhost bin]# chmod +x docker-compose
3. 验证
[root@localhost bin]# docker-compose version docker-compose version 1.29.2, build 5becea4c docker-py version: 5.0.0 CPython version: 3.7.10 OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
以上输出版本号则安装成功!
如果出现以下错误,则是没下载成功,重新下载
[root@localhost bin]# docker-compose version /usr/local/bin/docker-compose: line 1: syntax error near unexpected token `newline' /usr/local/bin/docker-compose: line 1: `<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'
(1)删除docker-compose
[root@localhost bin]# ls #查看下载目录下内容 docker-compose [root@localhost bin]# rm -rf docker-compose #删除docker-compose
(2)尝试用github下载(官方所给地址)- 建议跳过
[root@localhost bin]# curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 633 100 633 0 0 121 0 0:00:05 0:00:05 --:--:-- 171 0 12.1M 0 32187 0 0 111 0 31:52:30 0:04:48 31:47:42 0
等待很久很久,仍然下载处于下载中,放弃下载
(3)直接在windows浏览器中下载 Release 1.29.2 · docker/compose · GitHub
上传至centos7 /usr/local/bin目录下
(4)文件重命名
[root@localhost bin]# mv docker-compose-Linux-x86_64 docker-compose
(5)授权,查看版本号,此时安装成功
[root@localhost bin]# chmod +x docker-compose #授权(可执行文件) [root@localhost bin]# docker-compose version #查看版本信息 docker-compose version 1.29.2, build 5becea4c docker-py version: 5.0.0 CPython version: 3.7.10 OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
参考文档(官网):
Install Docker Compose | Docker Documentation