针对docker的部署是比较复杂的,一系列的命令足以让实施新手研究与学习个把月了,掺杂了业务的docker容器化部署更是复杂。面对问题我们需要引入docker-compose 工具来帮我们完成系列复杂指令。

手工安装

  1. 可以通过https://github.com/docker/compose/releases 官方地址下载最新的docker-compose(如:sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose 或者下载后直接上传到服务器指定位置即可)
  2. 如果系统没有安装curl,可以采用wget来安装(如:sudo wget -O /usr/local/bin/docker-compose https://github.com/docker/compose/releases/download/1.23.1/docker-compose-`uname -s`-`uname -m`)

c、增加执行权限

sudo chmod +x /usr/local/bin/docker-compose

d、测试安装结果

sudo docker-compose version

出现如下代码片段标识安装成功

Pip安装

  1. 通过pip -v检查pip 是否安装及版本
  2. yum -y install epel-release 安装pip基础
  3. yum install python-pip 安装pip的python 支持
  4. pip install --upgrade pip 完成pip的安装
  5. pip install docker-compose 来安装docker-compose

pip 安装异常

采用手工安装后通过docker-compose version 显示没有安装(这是由于网络原因导致下周失败)

  • pip安装后报“ReadTimeoutError: HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out”这是由于下载延迟导致,可以采用“pip --default-timeout=200 install -U docker-compose”。
  • pip安装报类似” pkg_resources.DistributionNotFound: backports.ssl-match-hostname>=3.5”错误,执行“pip install --upgrade backports.ssl_match_hostname”即可完成backports.ssl-match-hostname的更新。
  • pip安装报类似” Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall” 错误,请” sudo pip install --ignore-installed requests”更新模块,.
  • pip安装报类似” ipapython 4.5.4 has requirement dnspython>=1.15, but you'll have dnspython 1.12.0 which is incompatible” 错误,请” pip install psutil”
  • pip安装报类似” Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-Y6TDnU/psutil/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-pVb4Xe/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-Y6TDnU/psutil/”错误,请” yum install python-devel”
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐