Docker provides a container choreography tool, Docker Compose, which allows users to define a set of associated application containers in a template (YAML format). This set of containers will be based on the "– link" and other parameters in the configuration template. To automatically sort the priority of startup, simply execute a "Docker Compose up", you can create and start multiple containers in the same service in turn.
install
Method 1:
You can download it directly from github, provided that Docker is installed first, and the version is above 1.9.1
Note that Compose 1.8.0 requires Docker Engine 1.10.0 or later for version 2 of the Compose File format, and Docker Engine 1.9.1 or later for version 1.
curl -L https://github.com/docker/compose/releases/download/1.19.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
During the actual operation, the request address returned 404, and the installation failed.
You can also use the run.sh script of pip or official website to install
Method two:
Install via pip.
The centos installation pip command is as follows:
# yum -y install epel-release
# yum install python-pip
# pip install --upgrade pip
The command to install Pip in ubuntu is as follows:
$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install --upgrade pip
$ sudo pip install --upgrade virtualenv
After pip installation, install compose:
pip install docker-compose
Check whether the installation is successful through the command:
docker-compose
View docker compose version
docker-compose -v
Problem record
Because ubuntu uses curl mode to install docker 18.01.0-ce version, using the above method to directly install docker compose succeeded in one time.
root@lei-VirtualBox:/# docker --version
Docker version 18.01.0-ce, build 03596f5
root@lei-VirtualBox:/#
root@lei-VirtualBox:/# docker-compose -v
docker-compose version 1.18.0, build 8dd22a9
There was a problem installing centos. Install docker version 1.12.0 by default using yum. When installing docker compose in the above pip mode, run docker compose to report an error:
[root@localhost ~]# docker-compose
Traceback (most recent call last):
File "/usr/bin/docker-compose", line 7, in <module>
from compose.cli.main import main
File "/usr/lib/python2.7/site-packages/compose/cli/main.py", line 17, in <module>
import docker
File "/usr/lib/python2.7/site-packages/docker/__init__.py", line 2, in <module>
from .api import APIClient
File "/usr/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in <module>
from .client import APIClient
File "/usr/lib/python2.7/site-packages/docker/api/client.py", line 9, in <module>
import websocket
File "/usr/lib/python2.7/site-packages/websocket/__init__.py", line 23, in <module>
from ._app import WebSocketApp
File "/usr/lib/python2.7/site-packages/websocket/_app.py", line 35, in <module>
from ._core import WebSocket, getdefaulttimeout
File "/usr/lib/python2.7/site-packages/websocket/_core.py", line 33, in <module>
from ._handshake import *
File "/usr/lib/python2.7/site-packages/websocket/_handshake.py", line 30, in <module>
from ._http import *
File "/usr/lib/python2.7/site-packages/websocket/_http.py", line 33, in <module>
from ._url import *
File "/usr/lib/python2.7/site-packages/websocket/_url.py", line 27, in <module>
from six.moves.urllib.parse import urlparse
ImportError: No module named urllib.parse
The solution at this time is as follows (do not understand the reason):
pip install docker_pycreds
Check the compose version again and fix the problem.
[root@localhost ~]# docker -v
Docker version 1.12.6, build 3e8e77d/1.12.6
[root@localhost ~]# docker-compose -v
docker-compose version 1.19.0, build 9e633ef