mirror of https://github.com/docker/docs.git
added explanation of Compose files and commands (#3588)
* added explanation of Compose files and commands Signed-off-by: Victoria Bialas <victoria.bialas@docker.com> * improved note content, formatting Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>
This commit is contained in:
parent
3e29924bb3
commit
4dd375f587
Binary file not shown.
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 250 KiB |
|
@ -92,20 +92,44 @@ networks:
|
||||||
This `docker-compose.yml` file tells Docker to do the following:
|
This `docker-compose.yml` file tells Docker to do the following:
|
||||||
|
|
||||||
- Pull [the image we uploaded in step 2](part2.md) from the registry.
|
- Pull [the image we uploaded in step 2](part2.md) from the registry.
|
||||||
|
|
||||||
- Run five instances of that image as a service
|
- Run five instances of that image as a service
|
||||||
called `web`, limiting each one to use, at most, 10% of the CPU (across all
|
called `web`, limiting each one to use, at most, 10% of the CPU (across all
|
||||||
cores), and 50MB of RAM.
|
cores), and 50MB of RAM.
|
||||||
|
|
||||||
- Immediately restart containers if one fails.
|
- Immediately restart containers if one fails.
|
||||||
|
|
||||||
- Map port 80 on the host to `web`'s port 80.
|
- Map port 80 on the host to `web`'s port 80.
|
||||||
|
|
||||||
- Instruct `web`'s containers to share port 80 via a load-balanced network
|
- Instruct `web`'s containers to share port 80 via a load-balanced network
|
||||||
called `webnet`. (Internally, the containers themselves will publish to
|
called `webnet`. (Internally, the containers themselves will publish to
|
||||||
`web`'s port 80 at an ephemeral port.)
|
`web`'s port 80 at an ephemeral port.)
|
||||||
|
|
||||||
- Define the `webnet` network with the default settings (which is a
|
- Define the `webnet` network with the default settings (which is a
|
||||||
load-balanced overlay network).
|
load-balanced overlay network).
|
||||||
|
|
||||||
|
|
||||||
|
> Wondering about Compose file versions, names, and commands?
|
||||||
|
>
|
||||||
|
Notice that set the Compose file to `version: "3"`. This essentially makes it
|
||||||
|
[swarm mode](/engine/swarm/index.md) compatible. We can make use of the [deploy
|
||||||
|
key](/compose/compose-file/index.md#deploy) (only available on [Compose file
|
||||||
|
formats version 3.x](/compose/compose-file/index.md) and up) and its sub-options
|
||||||
|
to load balance and optimize performance for each service (e.g., `web`). We can
|
||||||
|
run the file with the `docker stack deploy` command (also only supported on
|
||||||
|
Compose files version 3.x and up). You could use `docker-compose up` to run
|
||||||
|
version 3 files with _non swarm_ configurations, but we are focusing on a stack
|
||||||
|
deployment since we are building up to a swarm example.
|
||||||
|
>
|
||||||
|
You can name the Compose file anything you want to make it logically meaningful
|
||||||
|
to you; `docker-compose.yml` is simply a standard name. We could just as easily
|
||||||
|
have called this file `docker-stack.yml` or something more specific to our
|
||||||
|
project.
|
||||||
|
{: .note-vanilla}
|
||||||
|
|
||||||
## Run your new load-balanced app
|
## Run your new load-balanced app
|
||||||
|
|
||||||
Before we can use the `docker stack deploy` command we'll first run
|
Before we can use the `docker stack deploy` command we'll first run:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker swarm init
|
docker swarm init
|
||||||
|
@ -114,7 +138,7 @@ docker swarm init
|
||||||
>**Note**: We'll get into the meaning of that command in [part 4](part4.md).
|
>**Note**: We'll get into the meaning of that command in [part 4](part4.md).
|
||||||
> If you don't run `docker swarm init` you'll get an error that "this node is not a swarm manager."
|
> If you don't run `docker swarm init` you'll get an error that "this node is not a swarm manager."
|
||||||
|
|
||||||
Now let's run it. You have to give your app a name -- here it is set to
|
Now let's run it. You have to give your app a name. Here, it is set to
|
||||||
`getstartedlab`:
|
`getstartedlab`:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|
Loading…
Reference in New Issue