【Docker】Docker学习⑨ - 单机编排之Docker Compose
一、Docker简介
二、Docker安装及基础命令介绍
三、Docker镜像管理
四、Docker镜像与制作
五、Docker数据管理
六、网络部分
七、Docker仓库之单机Dokcer Registry
八、Docker仓库之分布式Harbor
九、单机编排之Docker Compose
当在宿主机启动较多的容器的时候,如果都是手动操作会觉得比较麻烦而且容易出错,这个时候推荐使用docker单机编排工具docker compose,Dokcer Compose是docker容器的一种编排服务,docker compose是一个管理多个容器的工具,比如可以解决容器之间的依赖关系,就像启动一个web就必须得先把数据库服务先启动一样,docker compose完全可以替代docker run启动容器。
- github地址:https://github.com/docker/compose
1 基础环境准备
- 1.1 安装python环境及pip命令
yum install https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm -y
yum install python-pip -y
pip install --upgrade pip
- 1.2 安装docker compose
pip install docker-compose
- 1.3 验证版本
docker-compose version
日志:
[root@gbase8c_private ~]# docker-compose version
/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.hazmat.backends import default_backend
docker-compose version 1.26.2, build unknown
docker-py version: 4.4.4
CPython version: 2.7.5
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017
- 1.4 查看帮助
docker-compose --help
[root@gbase8c_private ~]# docker-compose --help
/usr/lib/python2.7/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.hazmat.backends import default_backend
Define and run multi-container applications with Docker.
Usage:
docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...]
docker-compose -h|--help
Options:
-f, --file FILE Specify an alternate compose file
(default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name
(default: directory name)
-c, --context NAME Specify a context name
--verbose Show more output
--log-level LEVEL Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
--no-ansi Do not print ANSI control characters
-v, --version Print version and exit
-H, --host HOST Daemon socket to connect to
--tls Use TLS; implied by --tlsverify
--tlscacert CA_PATH Trust certs signed only by this CA
--tlscert CLIENT_CERT_PATH Path to TLS certificate file
--tlskey TLS_KEY_PATH Path to TLS key file
--tlsverify Use TLS and verify the remote
--skip-hostname-check Don't check the daemon's hostname against the
name specified in the client certificate
--project-directory PATH Specify an alternate working directory
(default: the path of the Compose file)
--compatibility If set, Compose will attempt to convert keys
in v3 files to their non-Swarm equivalent
--env-file PATH Specify an alternate environment file
Commands:
build Build or rebuild services
config Validate and view the Compose