Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25b0aff

Browse files
Revert "Delete part4.md"
This reverts commit 66ff88e.
1 parent 599aeaf commit 25b0aff

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

getting-started/part4.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: "Getting Started, Part 4: Scaling Your App on a Cluster"
3+
---
4+
5+
In [Getting Started, Part 3: Stateful, Multi-container Applications](part3.md),
6+
we figured out how to relate containers to each other. We organized an
7+
application into two simple services -- a frontend and a backend -- and defined
8+
how they are linked together.
9+
10+
In Part 4, we are going to take this application, which all ran on one **host**
11+
(a virtual or physical machine), and deploy it onto a cluster of hosts, just
12+
like we would in production.
13+
14+
## Understanding Swarm clusters
15+
16+
Up until now you have been using Docker in a single-host mode on your local
17+
machine, which allows the client, which is the command-line interface (CLI), to
18+
make assumptions about how to operate. Namely, the client assumes that the
19+
Docker Daemon is running on the same host as the client. Single-host operations
20+
could also be done on remote machines with your client.
21+
22+
But Docker also can be switched into "swarm mode." A swarm is a group of hosts
23+
that are running Docker and have been joined into a cluster. After that has
24+
happened, you continue to run the Docker commands you're used to, but now the
25+
concept of a "host" changes from a single virtual or physical machine, to a
26+
swarm. And, "a single virtual or physical machine" is not referred to as a host,
27+
it's called a node -- or, a computing resource inside your cluster.
28+
29+
## Before we get started: signup and configuration
30+
31+
The easiest way to demonstrate all this is to use Docker Cloud, which manages
32+
clusters that you run on popular cloud providers, like Heroku, Amazon Web
33+
Services (AWS), and so on. Because AWS has a free tier of service, which lets
34+
you provision low-resource virtual machines for free, we're going to use that
35+
to learn these concepts. We're also not going to be using any of Docker Cloud's
36+
paid features, so let's dive in and deploy something!
37+
38+
### Sign up for AWS, and configure it
39+
40+
All we have to do to let Docker Cloud manage nodes for us on free-tier AWS is
41+
create a service policy that grants certain permissions, and apply that to an
42+
identity called a "role," using AWS's Identity and Access Management (IAM) tool.
43+
44+
- Go to [aws.amazon.com](https://aws.amazon.com) and sign up for an account. It's free.
45+
- Go to [the IAM panel](https://console.aws.amazon.com/iam/home#policies)
46+
- Click **Create Policy**, then **Create Your Own Policy**.
47+
- Name the policy `dockercloud-policy` and paste the following text in the
48+
space provided for **Policy Document**, then click **Create Policy**.
49+
50+
```json
51+
{
52+
"Version": "2012-10-17",
53+
"Statement": [
54+
{
55+
"Action": [
56+
"ec2:*",
57+
"iam:ListInstanceProfiles"
58+
],
59+
"Effect": "Allow",
60+
"Resource": "*"
61+
}
62+
]
63+
}
64+
```
65+
- Now [create a role](https://console.aws.amazon.com/iam/home#roles) with a name
66+
of your choice.
67+
- Select **Role for Cross-Account Access**, and in the submenu that opens select **Allows IAM users from a 3rd party AWS account to access this account**.
68+
- In the **Account ID** field, enter the ID for the Docker Cloud service: `689684103426`.
69+
- In the **External ID** field, enter your Docker Cloud username.
70+
- On the next screen, select the `dockercloud-policy` you created to attach to the role.
71+
- On next page review your entries and copy the full **Role ARN** string. The
72+
ARN string should look something like `arn:aws:iam::123456789123:role/dockercloud-role`. You'll use the ARN in the next step.
73+
- Finally, click **Create Role**.
74+
75+
And you've done it! Your AWS account will allow Docker Cloud to control
76+
virtual machines, if we configure Docker Cloud to use the role you've created.
77+
So, let's do that now.
78+
79+
> Note: If you had any trouble along the way, there are more detailed
80+
[instructions in the Docker Cloud docs](/docker-cloud/infrastructure/link-aws.md).
81+
If you'd like to use a cloud provider besides AWS, check out
82+
[the list](/docker-cloud/infrastructure/index.md). We're just using AWS here
83+
because you don't have to pay.
84+
85+
### Configure Docker Cloud to manage to your AWS instances
86+
87+
- Go to [cloud.docker.com](http://cloud.docker.com) and sign in with the
88+
same Docker ID you used in [part 2](/getting-started/part2.md).
89+
- Click **Settings**, and in the Cloud Providers section, click the plug icon.
90+
- Enter the Role ARN string you copied earlier, e.g. `arn:aws:iam::123456789123:role/dockercloud-role`.
91+
- Click **Save**.
92+
93+
And now, Docker Cloud can create and manage instances for you, and turn them
94+
into a swarm.
95+
96+
## Creating your first Swarm cluster
97+
98+
1. Go back to Docker Cloud by visiting [cloud.docker.com](https://cloud.docker.com).
99+
2. Click **Node Clusters** in the left navigation, then click the **Create** button.
100+
This pulls up a form where you can create our cluster.
101+
3. Leave everything default, except:
102+
- Name: Give your cluster a name
103+
- Region: Select a region that's close to you
104+
- Provider: Set to "Amazon Web Services"
105+
- Type/Size: Select the `t2.nano` option as that is free-tier
106+
4. Launch the cluster by clicking **Launch node cluster**; this will spin
107+
up a free-tier Amazon instance.
108+
5. Now, click **Services** in the left navigation, then the **Create** button,
109+
then the **globe icon**.
110+
6. Search Docker Hub for the image you uploaded
111+
112+
113+
[On to next >>](part5.md){: class="button darkblue-btn"}

0 commit comments

Comments
 (0)