|
@@ -5,26 +5,27 @@ page_keywords: documentation, docs, docker, compose, orchestration, containers
|
|
|
|
|
|
|
|
## Overview
|
|
## Overview
|
|
|
|
|
|
|
|
-Compose is a tool that allows you to orchestrate multiple Docker containers.
|
|
|
|
|
-With Compose, you can build clusters of containers which provide the resources
|
|
|
|
|
-(services, volumes, etc.) needed to build and run a complete distributed
|
|
|
|
|
-application.
|
|
|
|
|
|
|
+Compose is a tool for defining and running complex applications with Docker.
|
|
|
|
|
+With Compose, you define a multi-container application in a single file, then
|
|
|
|
|
+spin your application up in a single command which does everything that needs to
|
|
|
|
|
+be done to get it running.
|
|
|
|
|
|
|
|
-You can use Compose to build your app with containers hosted locally, or on a
|
|
|
|
|
-remote server, including cloud-based instances - anywhere a Docker daemon can
|
|
|
|
|
-run. Its primary use case is for development environments, but it can be used
|
|
|
|
|
-just as easily for staging or CI.
|
|
|
|
|
|
|
+Compose is great for development environments, staging servers, and CI. We don't
|
|
|
|
|
+recommend that you use it in production yet.
|
|
|
|
|
|
|
|
Using Compose is basically a three-step process.
|
|
Using Compose is basically a three-step process.
|
|
|
|
|
|
|
|
First, you define your app's environment with a `Dockerfile` so it can be
|
|
First, you define your app's environment with a `Dockerfile` so it can be
|
|
|
reproduced anywhere:
|
|
reproduced anywhere:
|
|
|
|
|
|
|
|
- FROM python:2.7
|
|
|
|
|
- WORKDIR /code
|
|
|
|
|
- ADD requirements.txt /code/
|
|
|
|
|
- RUN pip install -r requirements.txt
|
|
|
|
|
- ADD . /code
|
|
|
|
|
|
|
+```Dockerfile
|
|
|
|
|
+FROM python:2.7
|
|
|
|
|
+WORKDIR /code
|
|
|
|
|
+ADD requirements.txt /code/
|
|
|
|
|
+RUN pip install -r requirements.txt
|
|
|
|
|
+ADD . /code
|
|
|
|
|
+CMD python app.py
|
|
|
|
|
+```
|
|
|
|
|
|
|
|
Next, you define the services that make up your app in `docker-compose.yml` so
|
|
Next, you define the services that make up your app in `docker-compose.yml` so
|
|
|
they can be run together in an isolated environment:
|
|
they can be run together in an isolated environment:
|
|
@@ -32,7 +33,6 @@ they can be run together in an isolated environment:
|
|
|
```yaml
|
|
```yaml
|
|
|
web:
|
|
web:
|
|
|
build: .
|
|
build: .
|
|
|
- command: python app.py
|
|
|
|
|
links:
|
|
links:
|
|
|
- db
|
|
- db
|
|
|
ports:
|
|
ports:
|
|
@@ -41,16 +41,14 @@ db:
|
|
|
image: postgres
|
|
image: postgres
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-(No more installing Postgres on your laptop!)
|
|
|
|
|
-
|
|
|
|
|
Lastly, run `docker-compose up` and Compose will start and run your entire app.
|
|
Lastly, run `docker-compose up` and Compose will start and run your entire app.
|
|
|
|
|
|
|
|
-Compose includes commands to:
|
|
|
|
|
|
|
+Compose has commands for managing the whole lifecycle of your application:
|
|
|
|
|
|
|
|
* Start, stop and rebuild services
|
|
* Start, stop and rebuild services
|
|
|
* View the status of running services
|
|
* View the status of running services
|
|
|
- * tail the log output of running services
|
|
|
|
|
- * run a one-off command on a service
|
|
|
|
|
|
|
+ * Stream the log output of running services
|
|
|
|
|
+ * Run a one-off command on a service
|
|
|
|
|
|
|
|
|
|
|
|
|
## Quick start
|
|
## Quick start
|