Docker Compose

提供: Ubuntu入門
移動: 案内検索
スポンサーリンク

Docker Compose (Compose)とはは、Dockerで複雑なアプリケーションを定義、実行するためのツールです。1つのファイルにマルチコンテナアプリケーションを定義し、1つのコマンドでアプリケーションを実行します。実行するために必要なすべてが行われます。

読み方

Docker Compose
どっかー こんぽーず

概要

Docker Compose

インストール

$ sudo apt install libyaml-dev
$ sudo pip install -U docker-compose

libyaml-dev がないと yaml.h が見つからずにエラーになります。

$ sudo pip install -U docker-compose
Downloading/unpacking docker-compose
  Downloading docker-compose-1.1.0.tar.gz (47kB): 47kB downloaded
  Running setup.py (path:/tmp/pip_build_root/docker-compose/setup.py) egg_info
  for package docker-compose
 
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.un~' found anywhere in distribution
Downloading/unpacking docopt>=0.6.1,<0.7 (from docker-compose)
  Downloading docopt-0.6.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/docopt/setup.py) egg_info for package docopt
 
Downloading/unpacking PyYAML>=3.10,<4 from
https://pypi.python.org/packages/source/P/PyYAML/PyYAML-3.11.tar.gz#md5=f50e08ef0fe55178479d3a618efe21db
(from docker-compose)
  Downloading PyYAML-3.11.tar.gz (248kB): 248kB downloaded
  Running setup.py (path:/tmp/pip_build_root/PyYAML/setup.py) egg_info for package PyYAML
 
Downloading/unpacking requests>=2.2.1,<2.5.0 from
https://pypi.python.org/packages/2.7/r/requests/requests-2.4.3-py2.py3-none-any.whl#md5=0a66a9c4c22272680430fbb9fb4ca34f
(from docker-compose)
  Downloading requests-2.4.3-py2.py3-none-any.whl (459kB): 459kB downloaded
Downloading/unpacking texttable>=0.8.1,<0.9 (from docker-compose)
  Downloading texttable-0.8.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/texttable/setup.py) egg_info for package texttable
 
Downloading/unpacking websocket-client>=0.11.0,<1.0 (from docker-compose)
  Downloading websocket-client-0.25.0.tar.gz (188kB): 188kB downloaded
  Running setup.py (path:/tmp/pip_build_root/websocket-client/setup.py) egg_info for package websocket-client
 
Downloading/unpacking docker-py>=0.6.0,<0.8 (from docker-compose)
  Downloading docker-py-0.7.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/docker-py/setup.py) egg_info for package docker-py
 
Downloading/unpacking dockerpty>=0.3.2,<0.4 (from docker-compose)
  Downloading dockerpty-0.3.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/dockerpty/setup.py) egg_info for package dockerpty
 
Downloading/unpacking six>=1.3.0,<2 from
https://pypi.python.org/packages/3.3/s/six/six-1.9.0-py2.py3-none-any.whl#md5=9ac7e129a80f72d6fc1f0216f6e9627b
(from docker-compose)
  Downloading six-1.9.0-py2.py3-none-any.whl
Downloading/unpacking backports.ssl-match-hostname (from websocket-client>=0.11.0,<1.0->docker-compose)
  Downloading backports.ssl_match_hostname-3.4.0.2.tar.gz
  Running setup.py
  (path:/tmp/pip_build_root/backports.ssl-match-hostname/setup.py) egg_info
  for package backports.ssl-match-hostname
 
Installing collected packages: docker-compose, docopt, PyYAML, requests,
texttable, websocket-client, docker-py, dockerpty, six,
backports.ssl-match-hostname
  Running setup.py install for docker-compose
 
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    warning: no previously-included files matching '*.pyo' found anywhere in distribution
    warning: no previously-included files matching '*.un~' found anywhere in distribution
    Installing docker-compose script to /usr/local/bin
  Running setup.py install for docopt
 
  Found existing installation: PyYAML 3.10
    Uninstalling PyYAML:
      Successfully uninstalled PyYAML
  Running setup.py install for PyYAML
    checking if libyaml is compilable
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2
    -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c
    build/temp.linux-x86_64-2.7/check_libyaml.c -o
    build/temp.linux-x86_64-2.7/check_libyaml.o
    build/temp.linux-x86_64-2.7/check_libyaml.c:2:18: fatal error: yaml.h: No
    such file or directory
     #include <yaml.h>
                      ^
    compilation terminated.
 
    libyaml is not found or a compiler error: forcing --without-libyaml
    (if libyaml is installed correctly, you may need to
     specify the option --include-dirs or uncomment and
     modify the parameter include_dirs in setup.cfg)
 
  Found existing installation: requests 2.2.1
    Uninstalling requests:
      Successfully uninstalled requests
  Running setup.py install for texttable
 
  Running setup.py install for websocket-client
    changing mode of build/scripts-2.7/wsdump.py from 644 to 755
 
    changing mode of /usr/local/bin/wsdump.py to 755
  Running setup.py install for docker-py
 
  Running setup.py install for dockerpty
 
  Found existing installation: six 1.5.2
    Uninstalling six:
      Successfully uninstalled six
  Running setup.py install for backports.ssl-match-hostname
 
Successfully installed docker-compose docopt PyYAML requests texttable
websocket-client docker-py dockerpty six backports.ssl-match-hostname
Cleaning up...

設定

 

使い方

コマンドラインオプション

Fast, isolated development environments using Docker.
 
Usage:
  docker-compose [options] [COMMAND] [ARGS...]
  docker-compose -h|--help
 
Options:
  --verbose                 Show more output
  --version                 Print version and exit
  -f, --file FILE           Specify an alternate compose file (default: docker-compose.yml)
  -p, --project-name NAME   Specify an alternate project name (default: directory name)
 
Commands:
  build     Build or rebuild services
  help      Get help on a command
  kill      Kill containers
  logs      View output from containers
  port      Print the public port for a port binding
  ps        List containers
  pull      Pulls service images
  rm        Remove stopped containers
  run       Run a one-off command
  scale     Set number of containers for a service
  start     Start services
  stop      Stop services
  restart   Restart services
  up        Create and start containers

関連項目




スポンサーリンク