目前只尝试了linux x86架构在线安装
下载 docker-compose到 /usr/local/bin/ 中
$ sudo curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
[root@localhost bin]# docker-compose -version docker-compose version 1.21.2, build e7de1bc
linux x86只要把https://github.com/docker/compose/releases中的对应linux版本的docker-compose二进制文件下载到本地并发送linux下,复制到 /usr/local/bin/就可以正常使用。
从github上下载dockerCompoes源码。然后执行下面步骤:
- 进入到docker-compose的源码目录
- 执行python setup.py install
有些架构的docker-compose二进制文件官方没有提供,需要自己手动编译安装。其他官方没有提供的也需要自己手动使用python编译安装
经过尝试发现好像只有使用python编译可以成功安装,另外下面三种方式都失败了。
使用docker-compose github源码,python编译安装。
- 进入到docker-compose的源码目录
- 执行python setup.py install
一直再报requests10版本错误,删除10版本,换了16版本,又报docker必须的requests2.14以上,说明下载的docker-compose源码版本和安装的docker版本不对应.
下载并查看源码下的requirements.txt文件中的requests版本,找到和已安装的docker对应版本,然后再次安装,又报texttable版本不正确。而且无网络不能自动下载,只能手动到https://pypi.org/project/texttable/上面找对应版本下载,编译安装。
这类缺少依赖的问题都要到python官网下载,然后通过编译安装。一个例子:
安装requests、texttable两个依赖,并且docker-compose与docker版本对应。继续执行python编译安装
- 进入到docker-compose得源码目录
- 执行python setup.py install
报错:
Installed /usr/lib/python2.7/site-packages/docker_compose-1.21.2-py2.7.egg
Processing dependencies for docker-compose==1.21.2
Searching for docker<4.0,>=3.3.0
Reading https://pypi.python.org/simple/docker/
Download error on https://pypi.python.org/simple/docker/: [Errno -2] Name or service not known -- Some packages may not be found!
Couldn't retrieve index page for 'docker'
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [Errno -2] Name or service not known -- Some packages may not be found!
No local packages or download links found for docker<4.0,>=3.3.0
error: Could not find suitable distribution for Requirement.parse('docker<4.0,>=3.3.0')
原因:python下的docker版本错误,重新到https://pypi.python.org/simpl...,并编译安装
进入到下载得python docker3.3.0目录下
执行命令python setup.py install
输出:
...
...Using /usr/lib/python2.7/site-packages/idna-2.5-py2.7.egg
Searching for chardet==3.0.2
Best match: chardet 3.0.2
Processing chardet-3.0.2-py2.7.egg
chardet 3.0.2 is already the active version in easy-install.pth
Installing chardetect script to /usr/binUsing /usr/lib/python2.7/site-packages/chardet-3.0.2-py2.7.egg
Finished processing dependencies for docker==3.3.0
使用python安装docker-compose
[root@localhost docker-3.3.0]# cd ../docker-compose-1.21.2/ [root@localhost docker-compose-1.21.2]# ls build compose dist LICENSE README.rst setup.cfg tests CHANGELOG.md contrib docker_compose.egg-info MANIFEST.in requirements-dev.txt setup.py tox.ini CHANGES.md CONTRIBUTING.md Dockerfile [root@localhost docker-compose-1.21.2]# python setup.py install
最后安装成功显示:
Using /usr/lib/python2.7/site-packages/idna-2.5-py2.7.egg
Searching for chardet==3.0.2
Best match: chardet 3.0.2
Processing chardet-3.0.2-py2.7.egg
chardet 3.0.2 is already the active version in easy-install.pth
Installing chardetect script to /usr/binUsing /usr/lib/python2.7/site-packages/chardet-3.0.2-py2.7.egg
Finished processing dependencies for docker-compose==1.21.2
4.建立软连接
[root@localhost bin]# ln -s /usr/bin/docker-compose /usr/local/bin/docker-compose
5.验证一下
[root@localhost bin]# docker-compose -version docker-compose version 1.21.2, build e7de1bc
- 进入安装目录
- python setup.py build
- python setup.py install
其他尝试失败的安装方式
1.使用二进制文件安装
找编译好的二进制文件,尝试放到/usr/local/bin下面,报错:无法执行这个二进制文件。
2.使用dep安装
下载对应的dep安装包,解压data文件,把docker-compose放到/usr/local/bin下,执行报错:/usr/bin/python3:坏的的解释器
找镜像,找不到可用的镜像
您可能感兴趣的文章:
- docker-compose教程之安装使用和快速入门
- docker和docker-compose一键安装教程(支持在线和离线)
- 安装docker-compose的两种最简方法
- 安装docker和docker-compose实例详解
- Docker-compose的安装和设定详细步骤
- docker-compose安装Jenkins的实践笔记