安装 docker-compose

方法一: 二进制文件安装

我们可以在https://github.com/docker/compose/releases获取更多的二进制文件

  • 安装和添加执行权限命令
  1. 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. sudo chmod +x /usr/local/bin/docker-compose
  • 如下表示安装成功
  1. [root@localhost ~]# 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. % Total % Received % Xferd Average Speed Time Time Time Current
  3. Dload Upload Total Spent Left Speed
  4. 100 617 0 617 0 0 832 0 --:--:-- --:--:-- --:--:-- 832
  5. 100 10605k 100 10605k 0 0 245k 0 0:00:20 0:00:20 --:--:-- 10605k
  6. [root@localhost ~]# sudo chmod +x /usr/local/bin/docker-compose
  • 查看是否安装成功
  1. [root@localhost ~]# docker-compose -version
  2. docker-compose version 1.21.2, build a133471
方法二: pip安装

很多时候使用二进制方法安装不成功,我们可以使用python的pip方法进行安装

  • 先安装python-pip
  1. [root@localhost ~]# yum -y install epel-release
  2. [root@localhost ~]# yum -y install python-pip
  3. [root@localhost ~]# pip --version # 查看版本
  4. pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
  • 安装docker-compose
  1. [root@localhost ~]# pip install docker-compose

卸载docker-compose

docker-compose卸载只需要删除二进制文件就可以了。

  1. sudo rm /usr/local/bin/docker-compose