mirror of https://github.com/docker/docs.git
added node setup, create swarm, deploy topics to voting app example
Signed-off-by: Victoria Bialas <victoria.bialas@docker.com>
This commit is contained in:
parent
58220bcf61
commit
08df6cea16
|
@ -117,6 +117,16 @@ toc:
|
|||
title: Tag, push, & pull your image
|
||||
- path: /engine/getstarted/last_page/
|
||||
title: Learning more
|
||||
- sectiontitle: Deploy a multi-service app to Swarm
|
||||
section:
|
||||
- path: /engine/getstarted-voting-app/
|
||||
title: Voting app example and setup
|
||||
- path: /engine/getstarted-voting-app/node-setup/
|
||||
title: Set up Dockerized machines
|
||||
- path: /engine/getstarted-voting-app/create-swarm/
|
||||
title: Create a swarm
|
||||
- path: /engine/getstarted-voting-app/deploy-app/
|
||||
title: Deploy the app
|
||||
- sectiontitle: Learn by example
|
||||
section:
|
||||
- path: /engine/tutorials/dockerizing/
|
||||
|
|
|
@ -0,0 +1,140 @@
|
|||
---
|
||||
description: Setup for voting app example
|
||||
keywords: multi-container, services, swarm mode, cluster, voting app
|
||||
title: Create a swarm
|
||||
---
|
||||
|
||||
Now, we'll transform our Docker machines into a swarm.
|
||||
|
||||
1. Log on to the manager.
|
||||
|
||||
$ docker-machine ssh manager
|
||||
## .
|
||||
## ## ## ==
|
||||
## ## ## ## ## ===
|
||||
/"""""""""""""""""\___/ ===
|
||||
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
|
||||
\______ o __/
|
||||
\ \ __/
|
||||
\____\_______/
|
||||
_ _ ____ _ _
|
||||
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
|
||||
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
|
||||
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|
||||
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
|
||||
|
||||
WARNING: this is a build from test.docker.com, not a stable release.
|
||||
|
||||
Boot2Docker version 1.13.0-rc6, build HEAD : 5ab2289 - Wed Jan 11 23:37:52 UTC 2017
|
||||
Docker version 1.13.0-rc6, build 2f2d055
|
||||
|
||||
2. Initialize a swarm.
|
||||
|
||||
docker@manager:~$ docker swarm init --advertise-addr 192.168.99.100
|
||||
Swarm initialized: current node (ro5ak9ybe5qa62h7r81q29z0k) is now a manager.
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-4bk4romozl9ap5xpt0it6gzdwabtezs399go3fyaw1hy8t1kam-0xnovvmchc4wfe7xmh85faiwe \
|
||||
192.168.99.100:2377
|
||||
|
||||
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
|
||||
|
||||
### Add a worker node to the swarm
|
||||
|
||||
1. Log into the worker machine.
|
||||
|
||||
$ docker-machine ssh worker
|
||||
## .
|
||||
## ## ## ==
|
||||
## ## ## ## ## ===
|
||||
/"""""""""""""""""\___/ ===
|
||||
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
|
||||
\______ o __/
|
||||
\ \ __/
|
||||
\____\_______/
|
||||
_ _ ____ _ _
|
||||
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
|
||||
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
|
||||
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|
||||
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
|
||||
|
||||
WARNING: this is a build from test.docker.com, not a stable release.
|
||||
|
||||
Boot2Docker version 1.13.0-rc6, build HEAD : 5ab2289 - Wed Jan 11 23:37:52 UTC 2017
|
||||
Docker version 1.13.0-rc6, build 2f2d055
|
||||
|
||||
2. On the worker, run the join command given as the output of the `swarm init` command you ran on the manager.
|
||||
|
||||
docker@worker:~$ docker swarm join \
|
||||
> --token SWMTKN-1-4bk4romozl9ap5xpt0it6gzdwabtezs399go3fyaw1hy8t1kam-0xnovvmchc4wfe7xmh85faiwe \
|
||||
> 192.168.99.100:2377
|
||||
This node joined a swarm as a worker.
|
||||
|
||||
If you don't have the command, run `docker swarm join-token worker` on a manager node to retrieve the join command for a worker for this swarm.
|
||||
|
||||
### List the nodes in the swarm
|
||||
|
||||
Log into the manager and run `docker node ls`.
|
||||
|
||||
docker@manager:~$ docker node ls
|
||||
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
||||
dlosx9b74cgu4lh2qy54ebfp8 worker Ready Active
|
||||
ro5ak9ybe5qa62h7r81q29z0k * manager Ready Active Leader
|
||||
|
||||
## Deploy the app
|
||||
|
||||
In these steps, you'll use the `docker-stack.yml` file to deploy the application
|
||||
to the swarm you just created. To deploy an app deployed to a swarm You'll run
|
||||
the deploy command from the manager.
|
||||
|
||||
The `docker-stack.yml` file must be located on a manager for the swarm where you
|
||||
want to deploy the application stack.
|
||||
|
||||
1. Get `docker-stack.yml` either from the lab or by copying it from the
|
||||
example given here.
|
||||
|
||||
2. Copy `docker-stack.yml` from your host machine onto the manager.
|
||||
|
||||
$ docker-machine scp ~/sandbox/voting-app/docker-stack.yml manager:/home/docker/.
|
||||
docker-stack.yml 100% 1558 1.5KB/s 00:00
|
||||
|
||||
3. Log onto the manager.
|
||||
|
||||
$ docker-machine ssh manager
|
||||
|
||||
4. Check to make sure the `.yml` file is there.
|
||||
|
||||
docker@manager:~$ ls
|
||||
docker-stack.yml log.log
|
||||
|
||||
You can use `vi` or other text editor to inspect it.
|
||||
|
||||
5. Deploy the application stack based on the `.yml`.
|
||||
|
||||
docker@manager:~$ docker stack deploy --compose-file docker-stack.yml vote
|
||||
Creating network vote_default
|
||||
Creating network vote_backend
|
||||
Creating network vote_frontend
|
||||
Creating service vote_result
|
||||
Creating service vote_worker
|
||||
Creating service vote_visualizer
|
||||
Creating service vote_redis
|
||||
Creating service vote_db
|
||||
Creating service vote_vote
|
||||
|
||||
6. Verify that the stack deployed as expected with `docker stack services <appName>`.
|
||||
|
||||
docker@manager:~$ docker stack services vote
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
0y3q6lgc0drn vote_result replicated 2/2 dockersamples/examplevotingapp_result:before
|
||||
fvsaqvuec4yw vote_redis replicated 2/2 redis:alpine
|
||||
igev2xk5s3zo vote_worker replicated 1/1 dockersamples/examplevotingapp_worker:latest
|
||||
vpfjr9b0qc01 vote_visualizer replicated 1/1 dockersamples/visualizer:stable
|
||||
wctxjnwl22k4 vote_vote replicated 2/2 dockersamples/examplevotingapp_vote:before
|
||||
zp0zyvgaguox vote_db replicated 1/1 postgres:9.4
|
||||
|
||||
## What's next?
|
||||
|
||||
In the next step, we'll [deploy the voting app](deploy-app.md).
|
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
description: Setup for voting app example
|
||||
keywords: multi-container, services, swarm mode, cluster, voting app, docker-stack.yml, docker stack deploy
|
||||
title: Deploy the application
|
||||
---
|
||||
|
||||
In these steps, you'll use the `docker-stack.yml` file to deploy the application to the swarm you just created. You'll deploy from the `manager`.
|
||||
|
||||
## Copy `docker-stack.yml` to the manager
|
||||
|
||||
The `docker-stack.yml` file must be located on a manager for the swarm where you want to deploy the application stack.
|
||||
|
||||
1. Get `docker-stack.yml` either from the lab or by copying it from the example given here.
|
||||
|
||||
2. Copy `docker-stack.yml` from your host machine onto the manager.
|
||||
|
||||
$ docker-machine scp ~/sandbox/voting-app/docker-stack.yml manager:/home/docker/.
|
||||
docker-stack.yml 100% 1558 1.5KB/s 00:00
|
||||
|
||||
3. Log onto the `manager` node.
|
||||
|
||||
$ docker-machine ssh manager
|
||||
|
||||
4. Check to make sure the `.yml` file is there.
|
||||
|
||||
docker@manager:~$ ls
|
||||
docker-stack.yml log.log
|
||||
|
||||
You can use `vi` or other text editor to inspect it.
|
||||
|
||||
## Deploy the app
|
||||
|
||||
1. Deploy the application stack based on the `.yml` using the command `docker stack deploy` as follows.
|
||||
|
||||
docker@manager:~$ docker stack deploy --compose-file docker-stack.yml vote
|
||||
Creating network vote_default
|
||||
Creating network vote_backend
|
||||
Creating network vote_frontend
|
||||
Creating service vote_result
|
||||
Creating service vote_worker
|
||||
Creating service vote_visualizer
|
||||
Creating service vote_redis
|
||||
Creating service vote_db
|
||||
Creating service vote_vote
|
||||
|
||||
2. Verify that the stack deployed as expected with `docker stack services <appName>`.
|
||||
|
||||
docker@manager:~$ docker stack services vote
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
0y3q6lgc0drn vote_result replicated 2/2 dockersamples/examplevotingapp_result:before
|
||||
fvsaqvuec4yw vote_redis replicated 2/2 redis:alpine
|
||||
igev2xk5s3zo vote_worker replicated 1/1 dockersamples/examplevotingapp_worker:latest
|
||||
vpfjr9b0qc01 vote_visualizer replicated 1/1 dockersamples/visualizer:stable
|
||||
wctxjnwl22k4 vote_vote replicated 2/2 dockersamples/examplevotingapp_vote:before
|
||||
zp0zyvgaguox vote_db replicated 1/1 postgres:9.4
|
||||
|
||||
## What's next?
|
||||
|
||||
In the next steps, we'll view components of the running app on web pages. We
|
||||
will vote for cats and dogs, view the results, and monitor the manager and
|
||||
worker nodes, containers and services on a visualizer.
|
||||
|
||||
TO BE CONTINUED - WORK IN PROGRESS
|
|
@ -1,26 +1,50 @@
|
|||
---
|
||||
description: Getting started with multi-container Docker apps
|
||||
keywords: docker, container, multi-container, services, swarm mode, cluster, stack deploy, compose, voting app
|
||||
title: Get started with multi-container apps and services in swarm mode
|
||||
description: overview of voting app example
|
||||
keywords: docker-stack.yml, stack deploy, compose, container, multi-container, services, swarm mode, cluster, voting app,
|
||||
title: Learn about the voting app example and setup
|
||||
---
|
||||
|
||||
This tutorial is built around a web-based voting application that collects, tallies, and returns the results of votes (for cats and dogs, or other choices you specify). The voting app includes several services. We'll deploy the app as a _stack_ to introduce some new concepts surfaced in [Compose v.3](/compose/compose-file.md), and also use [swarm mode](/engine/swarm/index.md), which is built into Docker Engine.
|
||||
This example is built around a web-based voting application that collects,
|
||||
tallies, and returns the results of votes (for cats and dogs, or other choices
|
||||
you specify). The voting app includes several services, each one running in its
|
||||
own container. We'll deploy the app as a _stack_ to introduce some new concepts
|
||||
surfaced in [Compose v.3](/compose/compose-file.md), and also use [swarm
|
||||
mode](/engine/swarm/index.md), which is cluster management and orchestration
|
||||
capability built into Docker Engine.
|
||||
|
||||
## Got Docker?
|
||||
|
||||
If you haven't yet downloaded Docker or installed it, go to [Get Docker](https://www.docker.com/) and grab Docker for your platform. Once you have Docker installed, you can run `docker hello-world` or other commands described in the newcomer tutorial to [verify your installation](/engine/getstarted/step_one.md#step-3-verify-your-installation). If you are totally new to Docker, you might try the quick [newcomer tutorial](/engine/getstarted/index.md) first, then come back.
|
||||
If you haven't yet downloaded Docker or installed it, go to [Get
|
||||
Docker](/engine/getstarted/step_one.md#step-1-get-docker) and grab Docker for
|
||||
your platform. You can follow along and run this example using Docker for Mac,
|
||||
Docker for Windows or Docker for Linux.
|
||||
|
||||
Once you have Docker installed, you can run `docker hello-world`
|
||||
or other commands described in the newcomer tutorial to [verify your
|
||||
installation]
|
||||
(/engine/getstarted/step_one.md#step-3-verify-your-installation.md).
|
||||
If you are totally new to Docker, you might continue through the full [newcomer
|
||||
tutorial](/engine/getstarted/index.md) first, then come back.
|
||||
|
||||
## What you'll learn and do
|
||||
|
||||
You'll learn how to:
|
||||
In this tutorial, you'll learn how to:
|
||||
|
||||
* Use `docker machine` to create multiple virtual local hosts or dockerized cloud servers
|
||||
* Use `docker machine` to create multiple virtual local hosts or
|
||||
dockerized cloud servers
|
||||
* Use `docker` commands to set up and run a swarm with manager and worker nodes
|
||||
* Deploy the `vote` app by feeding our example `docker-stack.yml` file to `docker stack deploy`
|
||||
* Deploy the `vote` app by feeding our example `docker-stack.yml` file to
|
||||
the `docker stack deploy` command
|
||||
* Test the app by voting for cats and dogs, and viewing the results
|
||||
* Use the `visualizer` to explore and understand the runtime app and services
|
||||
* Update the `docker-stack.yml` and re-deploy the app using a different `vote` image to implement a vote on different choices
|
||||
|
||||
* Update the `docker-stack.yml` and re-deploy the app using a different
|
||||
`vote` image to implement a vote on different choices
|
||||
* Identify the differences between `docker-stack.yml` and
|
||||
`docker-compose.yml` files, which serve similar purposes and
|
||||
can be used somewhat interchangeably
|
||||
* Identify the differences between `docker compose up` and
|
||||
`docker stack deploy` commands, which serve similar purposes and
|
||||
can be used somewhat interchangeably
|
||||
|
||||
## Anatomy of the voting app
|
||||
|
||||
|
@ -36,12 +60,17 @@ The voting app you are about to deploy is composed of several services:
|
|||
| `db` | A PostgreSQL service which provides permanent storage on a host volume | Based on a `postgres` image, `postgres:9.4` |
|
||||
| `worker` | A background service that transfers votes from the queue to permanent storage | Based on a .NET image, `dockersamples/examplevotingapp_worker` |
|
||||
|
||||
Each service will run in its own container. Using swarm mode, we can also scale the application to deploy replicas of containerized services distributed across multiple nodes.
|
||||
Each service will run in its own container. Using swarm mode, we can also scale
|
||||
the application to deploy replicas of containerized services distributed across
|
||||
multiple nodes.
|
||||
|
||||
## docker-stack.yml
|
||||
For this tutorial, you need only have Docker running and the copy of `docker-stack.yml` we provide here.
|
||||
|
||||
This file defines all the services, their base images, and provides . You will use this file to deploy the app.
|
||||
We'll deploy the app using `docker-stack.yml`. To follow along with the
|
||||
example, you need only have Docker running and the copy of `docker-stack.yml` we
|
||||
provide here. This file defines all the services shown in the [table above](#anatomy-of-the-voting-app), their base images,
|
||||
configuration details such as ports and dependencies, and the swarm
|
||||
configuration.
|
||||
|
||||
```
|
||||
version: "3"
|
||||
|
@ -121,6 +150,9 @@ services:
|
|||
stop_grace_period: 1m30s
|
||||
volumes:
|
||||
- "/var/run/docker.sock:/var/run/docker.sock"
|
||||
deploy:
|
||||
placement:
|
||||
constraints: [node.role == manager]
|
||||
|
||||
networks:
|
||||
frontend:
|
||||
|
@ -130,208 +162,10 @@ volumes:
|
|||
db-data:
|
||||
```
|
||||
|
||||
## Set up Dockerized hosts
|
||||
To deploy the application, we will use the `docker-stack deploy` command with this `docker-stack.yml` file to pull the referenced images and launch the services in a swarm as configured in the `.yml`.
|
||||
|
||||
1. Create `manager1` and `worker1` machines:
|
||||
But first, we need to set up the hosts and create a swarm.
|
||||
|
||||
```
|
||||
$ docker-machine create --driver virtualbox manager1
|
||||
Running pre-create checks...
|
||||
Creating machine...
|
||||
(manager1) Copying /Users/victoriabialas/.docker/machine/cache/boot2docker.iso to /Users/victoriabialas/.docker/machine/machines/manager1/boot2docker.iso...
|
||||
(manager1) Creating VirtualBox VM...
|
||||
(manager1) Creating SSH key...
|
||||
(manager1) Starting the VM...
|
||||
(manager1) Check network to re-create if needed...
|
||||
(manager1) Waiting for an IP...
|
||||
Waiting for machine to be running, this may take a few minutes...
|
||||
Detecting operating system of created instance...
|
||||
Waiting for SSH to be available...
|
||||
Detecting the provisioner...
|
||||
Provisioning with boot2docker...
|
||||
Copying certs to the local machine directory...
|
||||
Copying certs to the remote machine...
|
||||
Setting Docker configuration on the remote daemon...
|
||||
Checking connection to Docker...
|
||||
Docker is up and running!
|
||||
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager1
|
||||
```
|
||||
## What's next?
|
||||
|
||||
2. Get the IP addresses of the machines.
|
||||
|
||||
```
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
manager1 * virtualbox Running tcp://192.168.99.100:2376 v1.13.0-rc6
|
||||
worker1 - virtualbox Running tcp://192.168.99.101:2376 v1.13.0-rc6
|
||||
```
|
||||
|
||||
## Create a swarm
|
||||
|
||||
1. Log on to the manager.
|
||||
|
||||
```
|
||||
$ docker-machine ssh manager
|
||||
## .
|
||||
## ## ## ==
|
||||
## ## ## ## ## ===
|
||||
/"""""""""""""""""\___/ ===
|
||||
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
|
||||
\______ o __/
|
||||
\ \ __/
|
||||
\____\_______/
|
||||
_ _ ____ _ _
|
||||
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
|
||||
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
|
||||
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|
||||
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
|
||||
|
||||
WARNING: this is a build from test.docker.com, not a stable release.
|
||||
|
||||
Boot2Docker version 1.13.0-rc6, build HEAD : 5ab2289 - Wed Jan 11 23:37:52 UTC 2017
|
||||
Docker version 1.13.0-rc6, build 2f2d055
|
||||
```
|
||||
|
||||
2. Initialize a swarm.
|
||||
|
||||
```
|
||||
docker@manager:~$ docker swarm init --advertise-addr 192.168.99.100
|
||||
Swarm initialized: current node (ro5ak9ybe5qa62h7r81q29z0k) is now a manager.
|
||||
|
||||
To add a worker to this swarm, run the following command:
|
||||
|
||||
docker swarm join \
|
||||
--token SWMTKN-1-4bk4romozl9ap5xpt0it6gzdwabtezs399go3fyaw1hy8t1kam-0xnovvmchc4wfe7xmh85faiwe \
|
||||
192.168.99.100:2377
|
||||
|
||||
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
|
||||
```
|
||||
|
||||
### Add a worker node to the swarm
|
||||
|
||||
1. Log into the worker machine.
|
||||
|
||||
```
|
||||
$ docker-machine ssh worker
|
||||
## .
|
||||
## ## ## ==
|
||||
## ## ## ## ## ===
|
||||
/"""""""""""""""""\___/ ===
|
||||
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
|
||||
\______ o __/
|
||||
\ \ __/
|
||||
\____\_______/
|
||||
_ _ ____ _ _
|
||||
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
|
||||
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
|
||||
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|
||||
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
|
||||
|
||||
WARNING: this is a build from test.docker.com, not a stable release.
|
||||
|
||||
Boot2Docker version 1.13.0-rc6, build HEAD : 5ab2289 - Wed Jan 11 23:37:52 UTC 2017
|
||||
Docker version 1.13.0-rc6, build 2f2d055
|
||||
```
|
||||
|
||||
2. On the worker, run the join command given as the output of the `swarm init` command you ran on the manager.
|
||||
|
||||
```
|
||||
docker@worker:~$ docker swarm join \
|
||||
> --token SWMTKN-1-4bk4romozl9ap5xpt0it6gzdwabtezs399go3fyaw1hy8t1kam-0xnovvmchc4wfe7xmh85faiwe \
|
||||
> 192.168.99.100:2377
|
||||
This node joined a swarm as a worker.
|
||||
```
|
||||
|
||||
If you don't have the command, run `docker swarm join-token worker` on a manager node to retrieve the join command for a worker for this swarm.
|
||||
|
||||
|
||||
### List the nodes in the swarm
|
||||
|
||||
Log into the manager and run `docker node ls`.
|
||||
|
||||
```
|
||||
docker@manager:~$ docker node ls
|
||||
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
||||
dlosx9b74cgu4lh2qy54ebfp8 worker Ready Active
|
||||
ro5ak9ybe5qa62h7r81q29z0k * manager Ready Active Leader
|
||||
```
|
||||
|
||||
## Deploy the app
|
||||
|
||||
In these steps, you'll use the `docker-stack.yml` file to deploy the application to the swarm you just created. To deploy an app deployed to a swarm You'll run the deploy command from the manager.
|
||||
|
||||
The `docker-stack.yml` file must be located on a manager for the swarm where you want to deploy the application stack.
|
||||
|
||||
1. Get `docker-stack.yml` either from the lab or by copying it from the example given here.
|
||||
|
||||
2. Copy `docker-stack.yml` from your host machine onto the manager.
|
||||
|
||||
```
|
||||
$ docker-machine scp ~/sandbox/voting-app/docker-stack.yml manager:/home/docker/.
|
||||
docker-stack.yml 100% 1558 1.5KB/s 00:00
|
||||
```
|
||||
|
||||
3. Log onto the manager.
|
||||
|
||||
```
|
||||
$ docker-machine ssh manager1
|
||||
```
|
||||
|
||||
4. Check to make sure the `.yml` file is there.
|
||||
|
||||
```
|
||||
docker@manager:~$ ls
|
||||
docker-stack.yml log.log
|
||||
```
|
||||
|
||||
You can use `vi` or other text editor to inspect it.
|
||||
|
||||
5. Deploy the application stack based on the `.yml`.
|
||||
|
||||
```
|
||||
docker@manager:~$ docker stack deploy --compose-file docker-stack.yml vote
|
||||
Creating network vote_default
|
||||
Creating network vote_backend
|
||||
Creating network vote_frontend
|
||||
Creating service vote_result
|
||||
Creating service vote_worker
|
||||
Creating service vote_visualizer
|
||||
Creating service vote_redis
|
||||
Creating service vote_db
|
||||
Creating service vote_vote
|
||||
```
|
||||
|
||||
6. Verify that the stack deployed as expected with `docker stack services <appName>`.
|
||||
|
||||
```
|
||||
docker@manager:~$ docker stack services vote
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
0y3q6lgc0drn vote_result replicated 2/2 dockersamples/examplevotingapp_result:before
|
||||
fvsaqvuec4yw vote_redis replicated 2/2 redis:alpine
|
||||
igev2xk5s3zo vote_worker replicated 1/1 dockersamples/examplevotingapp_worker:latest
|
||||
vpfjr9b0qc01 vote_visualizer replicated 1/1 dockersamples/visualizer:stable
|
||||
wctxjnwl22k4 vote_vote replicated 2/2 dockersamples/examplevotingapp_vote:before
|
||||
zp0zyvgaguox vote_db replicated 1/1 postgres:9.4
|
||||
```
|
||||
|
||||
## Next topic
|
||||
|
||||
TBD
|
||||
|
||||
## Next topic
|
||||
|
||||
TBD
|
||||
|
||||
## Where to go next
|
||||
|
||||
The voting app is also available as a [lab on
|
||||
GitHub](https://github.com/docker/labs/blob/master/beginner/chapters/votingapp.md)
|
||||
along with the complete [source
|
||||
code]((https://github.com/docker/example-voting-app).
|
||||
|
||||
The lab is a deeper dive, and includes a few more tasks, like cloning a GitHub
|
||||
repository, manually changing source code, and rebuilding an image instead of
|
||||
using the ready-baked images referenced here.
|
||||
|
||||
|
||||
|
||||
In the next step, we'll [set up two Dockerized hosts](node-setup.md).
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
---
|
||||
description: Setup for voting app example
|
||||
keywords: docker-machine, multi-container, services, swarm mode, cluster, voting app
|
||||
title: Set up Dockerized machines
|
||||
---
|
||||
|
||||
The first step in getting the voting app deployed is to set up Docker machines
|
||||
for the swarm nodes. You could create these Docker hosts on different physical
|
||||
machines, virtual machines, or cloud providers.
|
||||
|
||||
For this example, we use [Docker Machine](/machine/get-started.md) to create two
|
||||
virtual machines on a single system. (See [Docker Machine
|
||||
Overview](/machine/overview.md) to learn more.) We'll also verify the setup, and
|
||||
run some basic commmands to interact with the machines.
|
||||
|
||||
## Create `manager` and `worker` machines
|
||||
|
||||
The Docker Machine command to create a local virtual machine is:
|
||||
|
||||
```
|
||||
docker-machine create --driver virtualbox <host-name>
|
||||
```
|
||||
|
||||
Here is an example of creating the manager. Create this one, then do the same for `worker`.
|
||||
|
||||
```
|
||||
$ docker-machine create --driver virtualbox manager
|
||||
Running pre-create checks...
|
||||
Creating machine...
|
||||
(manager) Copying /Users/victoria/.docker/machine/cache/boot2docker.iso to /Users/victoria/.docker/machine/machines/manager/boot2docker.iso...
|
||||
(manager) Creating VirtualBox VM...
|
||||
(manager) Creating SSH key...
|
||||
(manager) Starting the VM...
|
||||
(manager) Check network to re-create if needed...
|
||||
(manager) Waiting for an IP...
|
||||
Waiting for machine to be running, this may take a few minutes...
|
||||
Detecting operating system of created instance...
|
||||
Waiting for SSH to be available...
|
||||
Detecting the provisioner...
|
||||
Provisioning with boot2docker...
|
||||
Copying certs to the local machine directory...
|
||||
Copying certs to the remote machine...
|
||||
Setting Docker configuration on the remote daemon...
|
||||
Checking connection to Docker...
|
||||
Docker is up and running!
|
||||
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env manager
|
||||
```
|
||||
|
||||
## Get the IP addresses of the machines
|
||||
|
||||
Use `docker-machine ls` to verify that the machines are running and to get their
|
||||
IP addresses.
|
||||
|
||||
```
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
manager * virtualbox Running tcp://192.168.99.100:2376 v1.13.0-rc6
|
||||
worker - virtualbox Running tcp://192.168.99.101:2376 v1.13.0-rc6
|
||||
```
|
||||
You now have two "Dockerized" machines, each running Docker Engine, accessible through the [Docker CLI](/engine/reference/commandline.md), and available to become swarm nodes.
|
||||
|
||||
## Interacting with the machines
|
||||
|
||||
There are several ways to interact with these machines directly on the command line or programatically. We'll cover two methods for managing the machines directly from the command line.
|
||||
|
||||
### Get the environment commands for your new VM
|
||||
|
||||
As noted in the last line of output of the `docker-machine create` command, you need to tell Docker to talk to the new machine from a current shell. You can do this with the `docker-machine env` command.
|
||||
|
||||
#### Manage the machines from a command shell
|
||||
|
||||
1. Run `docker-machine env manager` to get environment variables for that machine.
|
||||
|
||||
$ docker-machine env manager
|
||||
export DOCKER_TLS_VERIFY="1"
|
||||
export DOCKER_HOST="tcp://192.168.99.100:2376"
|
||||
export DOCKER_CERT_PATH="/Users/victoriabialas/.docker/machine/machines/manager"
|
||||
export DOCKER_MACHINE_NAME="manager"
|
||||
export DOCKER_API_VERSION="1.25"
|
||||
# Run this command to configure your shell:
|
||||
# eval $(docker-machine env manager)
|
||||
|
||||
2. Connect your shell to the manager.
|
||||
|
||||
$ eval $(docker-machine env manager)
|
||||
|
||||
This sets environment variables for the current shell that the Docker client will read which specify the TLS settings. You need to do this each time you open a new shell or restart your machine.
|
||||
|
||||
**Note**: If you are using `fish`, or a Windows shell such as
|
||||
Powershell/`cmd.exe` the above method will not work as described.
|
||||
Instead, see the [env command reference documentation](/machine/reference/env.md) to learn how to set the environment variables for your shell.
|
||||
|
||||
3. Run `docker-machine ls` again.
|
||||
|
||||
$ docker-machine ls
|
||||
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
|
||||
manager * virtualbox Running tcp://192.168.99.100:2376 v1.13.0-rc6
|
||||
worker - virtualbox Running tcp://192.168.99.101:2376 v1.13.0-rc6
|
||||
|
||||
The asterisk next `manager` indicates that the current shell is connected to that machine.
|
||||
|
||||
#### Log on to a machine directly
|
||||
|
||||
You can use the command `docker-machine ssh <machine-name>` to log onto a machine:
|
||||
|
||||
```
|
||||
$ docker-machine ssh manager
|
||||
## .
|
||||
## ## ## ==
|
||||
## ## ## ## ## ===
|
||||
/"""""""""""""""""\___/ ===
|
||||
~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ / ===- ~~~
|
||||
\______ o __/
|
||||
\ \ __/
|
||||
\____\_______/
|
||||
_ _ ____ _ _
|
||||
| |__ ___ ___ | |_|___ \ __| | ___ ___| | _____ _ __
|
||||
| '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
|
||||
| |_) | (_) | (_) | |_ / __/ (_| | (_) | (__| < __/ |
|
||||
|_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
|
||||
|
||||
WARNING: this is a build from test.docker.com, not a stable release.
|
||||
|
||||
Boot2Docker version 1.13.0-rc6, build HEAD : 5ab2289 - Wed Jan 11 23:37:52 UTC 2017
|
||||
Docker version 1.13.0-rc6, build 2f2d055
|
||||
```
|
||||
|
||||
We'll use this method later in the example.
|
||||
|
||||
## What's next?
|
||||
|
||||
In the next step, we'll [create a swarm](create-swarm.md) across these two Docker nodes.
|
Loading…
Reference in New Issue