Skip to content

Commit 1af3fdb

Browse files
Merge pull request #1175 from londoncalling/voting-app-example-draft2
WIP: voting app example updated Compose v3 features
2 parents 971b2d3 + 571c539 commit 1af3fdb

File tree

1 file changed

+52
-51
lines changed

1 file changed

+52
-51
lines changed

engine/getstarted-voting-app/index.md

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,36 @@ Each service will run in its own container. Using swarm mode,
5858
we can also scale the application to deploy replicas
5959
of containerized services distributed across multiple nodes.
6060

61+
Here is an example of one of the services fully defined:
62+
63+
```
64+
vote:
65+
image: dockersamples/examplevotingapp_vote:before
66+
ports:
67+
- 5000:80
68+
networks:
69+
- frontend
70+
depends_on:
71+
- redis
72+
deploy:
73+
replicas: 2
74+
update_config:
75+
parallelism: 2
76+
restart_policy:
77+
condition: on-failure
78+
```
79+
80+
The `image` key defines which image the service will use. The `vote` service
81+
uses `dockersamples/examplevotingapp_vote:before`.
82+
83+
The `depends_on` key allows you to specify that a service is only
84+
deployed after another service. In our example, `vote` only deploys
85+
after `redis`.
86+
87+
The `deploy` key specifies aspects of a swarm deployment, as described below in
88+
[Compose v.3 features and
89+
compatibility](#compose-v3-features-and-compatibility).
90+
6191
## docker-stack.yml
6292

6393
We'll deploy the app using `docker-stack.yml`, which is a
@@ -68,8 +98,8 @@ To follow along with the example, you need only have
6898
Docker running and the copy of `docker-stack.yml` we
6999
provide here. This file defines all the services shown
70100
in the [table above](#anatomy-of-the-voting-app), their
71-
base images, configuration details such as ports
72-
and dependencies, and the swarm configuration.
101+
base images, configuration details such as ports and networks,
102+
application dependencies, and the swarm configuration.
73103

74104
```
75105
version: "3"
@@ -167,60 +197,27 @@ To deploy the voting application, we will use the `docker-stack deploy` command
167197
with this `docker-stack.yml` file to pull the referenced images and launch the
168198
services in a swarm as configured in the `.yml`.
169199

170-
Note that at the top of the `docker-stack.yml` file, the
171-
version is indicated as `version: "3" `. This voting app
172-
example relies on Compose version 3 features.
200+
Note that at the top of the `docker-stack.yml` file, the version is indicated as
201+
`version: "3" `. The voting app example relies on Compose version 3, which is
202+
designed to be cross-compatible with Compose and Docker Engine swarm mode.
173203

174-
Before we get started, let's take
175-
a look at some aspects of Compose files and deployment
176-
options that are new in Compose v.3, and that we want
177-
to highlight in this walkthrough.
204+
Before we get started, let's take a look at some aspects of Compose files and
205+
deployment options that are new in Compose v.3, and that we want to highlight in
206+
this walkthrough.
178207

179208
- [docker-stack.yml](#docker-stackyml)
180-
- [services key](#services-key)
181-
- [image key](#image-key)
182209
- [deploy key](#deploy-key)
183-
- [depends_on key](#dependson-key)
184210
- [docker stack deploy command](#docker-stack-deploy-command)
185-
- [Application stacks and services](#application-stacks-and-services)
211+
- [Application stacks and services](#application-stack-and-services)
186212

187213
### docker-stack.yml
188214

189215
`docker-stack.yml` is a new type of Compose file only compatible with Compose
190216
v.3.
191217

192-
#### services key
193-
194-
`services` is a new top-level key, under which there is a separate key for each
195-
of the services.
196-
197-
Here is an example of one of the services:
198-
199-
```
200-
vote:
201-
image: dockersamples/examplevotingapp_vote:before
202-
ports:
203-
- 5000:80
204-
networks:
205-
- frontend
206-
depends_on:
207-
- redis
208-
deploy:
209-
replicas: 2
210-
update_config:
211-
parallelism: 2
212-
restart_policy:
213-
condition: on-failure
214-
```
215-
216-
#### image key
217-
218-
The `image` key defines which image the service will use. The `vote` service
219-
uses `dockersamples/examplevotingapp_vote:before`.
220-
221218
#### deploy key
222219

223-
The `deploy` key is new in v.3, and allows you to specify various properties of
220+
The `deploy` key allows you to specify various properties of
224221
a swarm deployment.
225222

226223
For example, the voting app configuration uses this to
@@ -230,12 +227,6 @@ be deployed to the swarm).
230227
The voting app also uses the `deploy` key to
231228
constrain some services to run only on the manager node.
232229

233-
#### depends_on key
234-
235-
The `depends_on` key allows you to specify that a service is only
236-
deployed after another service. In our example, `vote` only deploys
237-
after `redis`.
238-
239230
### docker stack deploy command
240231

241232
`docker stack deploy` is the command we will use to deploy with
@@ -254,10 +245,20 @@ v.3 compatible applications.
254245

255246
Taken together, these new features and deployment options can help when
256247
mapping out distributed applications and clustering strategies. Rather than
257-
thinking about running individual containers, perse, we can start to model
248+
thinking about running individual containers, we can start to model
258249
Docker deployments as application stacks and services.
259250

260-
For more about `docker-stack.yml` and the `docker stack deploy` command, see [deploy](/compose/compose-file.md#deploy) in the [Compose file reference](/compose/compose-file.md).
251+
### Compose file reference
252+
253+
To learn more, see these topics in the [Compose file
254+
reference](/compose/compose-file.md):
255+
256+
* For more about `docker-stack.yml` and the `docker stack deploy` command, see
257+
[deploy](/compose/compose-file.md#deploy).
258+
259+
* For more on what's new in Compose v.3, see
260+
[Versioning](/compose/compose-file.md#versioning), [Version 3](/compose/compose-file.md#version-3), and
261+
[Upgrading](/compose/compose-file.md#upgrading).
261262

262263
## What's next?
263264

0 commit comments

Comments
 (0)