mirror of https://github.com/docker/compose.git
resolve most of my comments
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
parent
461f1ad5d5
commit
3b7ea5c055
|
@ -1,24 +1,32 @@
|
||||||
page_title: Compose: Multi-container orchestration for Docker
|
page_title: Compose: Multi-container orchestration for Docker
|
||||||
page_description: Introduction and Overview of Compose
|
page_description: Introduction and Overview of Compose
|
||||||
page_keywords: documentation, docs, docker, compose, orchestration, containers
|
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 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.
|
||||||
|
|
||||||
You can use Compose to build your app with containers hosted locally, or on a remote server, including cloud-based instances. Compose can also be used to deploy code to production.
|
You can use Compose to build your app with containers hosted locally, or on a
|
||||||
|
remote server, including cloud-based instances. Compose can also be used to
|
||||||
|
deploy code to production.
|
||||||
|
|
||||||
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 reproduced anywhere:
|
First, you define your app's environment with a `Dockerfile` so it can be
|
||||||
|
reproduced anywhere:
|
||||||
|
|
||||||
FROM python:2.7
|
FROM python:2.7
|
||||||
ADD . /code
|
|
||||||
WORKDIR /code
|
WORKDIR /code
|
||||||
|
ADD rements.txt /code/
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
|
ADD . /code
|
||||||
|
|
||||||
Next, you define the services that make up your app in `docker-compose.yml` so they can be run together in an isolated environment:
|
Next, you define the services that make up your app in `docker-compose.yml` so
|
||||||
|
they can be run together in an isolated environment:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
web:
|
web:
|
||||||
|
@ -46,7 +54,10 @@ Compose includes commands to:
|
||||||
|
|
||||||
## Quick start
|
## Quick start
|
||||||
|
|
||||||
Let's get started with a walkthrough of getting a simple Python web app running on Compose. It assumes a little knowledge of Python, but the concepts demonstrated here should be understandable even if you're not familiar with Python.
|
Let's get started with a walkthrough of getting a simple Python web app running
|
||||||
|
on Compose. It assumes a little knowledge of Python, but the concepts
|
||||||
|
demonstrated here should be understandable even if you're not familiar with
|
||||||
|
Python.
|
||||||
|
|
||||||
### Installation and set-up
|
### Installation and set-up
|
||||||
|
|
||||||
|
@ -84,7 +95,8 @@ Next, define the Python dependencies in a file called `requirements.txt`:
|
||||||
### Create a Docker image
|
### Create a Docker image
|
||||||
|
|
||||||
Now, create a Docker image containing all of your app's dependencies. You
|
Now, create a Docker image containing all of your app's dependencies. You
|
||||||
specify how to build the image using a file called [`Dockerfile`](http://docs.docker.com/reference/builder/):
|
specify how to build the image using a file called
|
||||||
|
[`Dockerfile`](http://docs.docker.com/reference/builder/):
|
||||||
|
|
||||||
FROM python:2.7
|
FROM python:2.7
|
||||||
ADD . /code
|
ADD . /code
|
||||||
|
@ -93,7 +105,9 @@ specify how to build the image using a file called [`Dockerfile`](http://docs.do
|
||||||
|
|
||||||
This tells Docker to include Python, your code, and your Python dependencies in
|
This tells Docker to include Python, your code, and your Python dependencies in
|
||||||
a Docker image. For more information on how to write Dockerfiles, see the
|
a Docker image. For more information on how to write Dockerfiles, see the
|
||||||
[Docker user guide](https://docs.docker.com/userguide/dockerimages/#building-an-image-from-a-dockerfile) and the
|
[Docker user
|
||||||
|
guide](https://docs.docker.com/userguide/dockerimages/#building-an-image-from-a-dockerfile)
|
||||||
|
and the
|
||||||
[Dockerfile reference](http://docs.docker.com/reference/builder/).
|
[Dockerfile reference](http://docs.docker.com/reference/builder/).
|
||||||
|
|
||||||
### Define services
|
### Define services
|
||||||
|
@ -115,12 +129,13 @@ Next, define a set of services using `docker-compose.yml`:
|
||||||
This defines two services:
|
This defines two services:
|
||||||
|
|
||||||
- `web`, which is built from the `Dockerfile` in the current directory. It also
|
- `web`, which is built from the `Dockerfile` in the current directory. It also
|
||||||
says to run the command `python app.py` inside the image, forward the exposed
|
says to run the command `python app.py` inside the image, forward the exposed
|
||||||
port 5000 on the container to port 5000 on the host machine, connect up the
|
port 5000 on the container to port 5000 on the host machine, connect up the
|
||||||
Redis service, and mount the current directory inside the container so we can
|
Redis service, and mount the current directory inside the container so we can
|
||||||
work on code without having to rebuild the image.
|
work on code without having to rebuild the image.
|
||||||
- `redis`, which uses the public image [redis](https://registry.hub.docker.com/_/redis/), which gets pulled from the
|
- `redis`, which uses the public image
|
||||||
Docker Hub registry.
|
[redis](https://registry.hub.docker.com/_/redis/), which gets pulled from the
|
||||||
|
Docker Hub registry.
|
||||||
|
|
||||||
### Build and run your app with Compose
|
### Build and run your app with Compose
|
||||||
|
|
||||||
|
@ -135,8 +150,8 @@ image for your code, and start everything up:
|
||||||
redis_1 | [8] 02 Jan 18:43:35.576 # Server started, Redis version 2.8.3
|
redis_1 | [8] 02 Jan 18:43:35.576 # Server started, Redis version 2.8.3
|
||||||
web_1 | * Running on http://0.0.0.0:5000/
|
web_1 | * Running on http://0.0.0.0:5000/
|
||||||
|
|
||||||
The web app should now be listening on port 5000 on your docker daemon (if
|
The web app should now be listening on port 5000 on your Docker daemon host (if
|
||||||
you're using boot2docker, `boot2docker ip` will tell you its address).
|
you're using Boot2docker, `boot2docker ip` will tell you its address).
|
||||||
|
|
||||||
If you want to run your services in the background, you can pass the `-d` flag
|
If you want to run your services in the background, you can pass the `-d` flag
|
||||||
(for daemon mode) to `docker-compose up` and use `docker-compose ps` to see what
|
(for daemon mode) to `docker-compose up` and use `docker-compose ps` to see what
|
||||||
|
@ -146,7 +161,7 @@ is currently running:
|
||||||
Starting composetest_redis_1...
|
Starting composetest_redis_1...
|
||||||
Starting composetest_web_1...
|
Starting composetest_web_1...
|
||||||
$ docker-compose ps
|
$ docker-compose ps
|
||||||
Name Command State Ports
|
Name Command State Ports
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
composetest_redis_1 /usr/local/bin/run Up
|
composetest_redis_1 /usr/local/bin/run Up
|
||||||
composetest_web_1 /bin/sh -c python app.py Up 5000->5000/tcp
|
composetest_web_1 /bin/sh -c python app.py Up 5000->5000/tcp
|
||||||
|
@ -164,4 +179,6 @@ your services once you've finished with them:
|
||||||
|
|
||||||
$ docker-compose stop
|
$ docker-compose stop
|
||||||
|
|
||||||
At this point, you have seen the basics of how Compose works. See the reference section for complete details on the commands, configuration file and environment variables.
|
At this point, you have seen the basics of how Compose works. See the reference
|
||||||
|
section for complete details on the commands, configuration file and environment
|
||||||
|
variables.
|
||||||
|
|
Loading…
Reference in New Issue