Docker 简明教程
Docker - Cloud
Docker Cloud 是 Docker 提供的一项服务,可以在其中执行下列操作 −
The Docker Cloud is a service provided by Docker in which you can carry out the following operations −
-
Nodes − You can connect the Docker Cloud to your existing cloud providers such as Azure and AWS to spin up containers on these environments.
-
Cloud Repository − Provides a place where you can store your own repositories.
-
Continuous Integration − Connect with Github and build a continuous integration pipeline.
-
Application Deployment − Deploy and scale infrastructure and containers.
-
Continuous Deployment − Can automate deployments.
Getting started
你可以通过以下链接开始使用 Docker Cloud − https://cloud.docker.com/
You can go to the following link to getting started with Docker Cloud − https://cloud.docker.com/
登录后,会提供以下基本界面 −
Once logged in, you will be provided with the following basic interface −
Connecting to the Cloud Provider
第一步是连接到现有的云提供商。下列步骤将向你展示如何连接到 Amazon Cloud 提供商。
The first step is to connect to an existing cloud provider. The following steps will show you how to connect with an Amazon Cloud provider.
Step 1 − 第一步是确保你有正确的 AWS 密钥。这可以从 aws 控制台中获取。使用下列链接登录你的 aws 帐户 − https://aws.amazon.com/console/
Step 1 − The first step is to ensure that you have the right AWS keys. This can be taken from the aws console. Log into your aws account using the following link − https://aws.amazon.com/console/
Step 2 − 登录后,转至安全性凭证部分。记下 Docker Hub 将使用的访问密钥。
Step 2 − Once logged in, go to the Security Credentials section. Make a note of the access keys which will be used from Docker Hub.
Step 3 − 接下来,您需要在 aws 中创建一个策略,允许 Docker 查看 EC2 实例。转至 aws 中的个人资料部分。单击 Create Policy 按钮。
Step 3 − Next, you need to create a policy in aws that will allow Docker to view EC2 instances. Go to the profiles section in aws. Click the Create Policy button.
Step 4 − 单击“创建您自己的策略”,并将策略名称指定为 dockercloudpolicy ,并将策略定义指定为如下所示。
Step 4 − Click on ‘Create Your Own Policy’ and give the policy name as dockercloudpolicy and the policy definition as shown below.
{
"Version": "2012-10-17",
"Statement": [ {
"Action": [
"ec2:*",
"iam:ListInstanceProfiles"
],
"Effect": "Allow",
"Resource": "*"
} ]
}
接下来,单击 Create Policy 按钮。
Next, click the Create Policy button
Step 5 − 接下来,您需要创建一个 role ,Docker 将使用它在 AWS 上启动节点。为此,请转至 AWS 中的 Roles 部分并单击 Create New Role 选项。
Step 5 − Next, you need to create a role which will be used by Docker to spin up nodes on AWS. For this, go to the Roles section in AWS and click the Create New Role option.
Step 6 − 将角色的名称指定为 dockercloud-role 。
Step 6 − Give the name for the role as dockercloud-role.
Step 7 − 在下一个屏幕上,转至“跨帐户访问角色”并选择“在您的帐户和第三方 AWS 帐户之间提供访问权限”。
Step 7 − On the next screen, go to ‘Role for Cross Account Access’ and select “Provide access between your account and a 3rd party AWS account".
Step 8 − 在下一个屏幕上,输入以下详细信息 −
Step 8 − On the next screen, enter the following details −
-
In the Account ID field, enter the ID for the Docker Cloud service: 689684103426.
-
In the External ID field, enter your Docker Cloud username.
Step 9 − 然后,单击 Next Step 按钮,在下一个屏幕上,附加在上一步中创建的策略。
Step 9 − Then, click the Next Step button and on the next screen, attach the policy which was created in the earlier step.
Step 10 − 最后,在创建角色的最后一个屏幕上,请务必复制创建的 arn 角色。
Step 10 − Finally, on the last screen when the role is created, make sure to copy the arn role which is created.
arn:aws:iam::085363624145:role/dockercloud-role
Step 11 − 现在返回 Docker Cloud ,选择 Cloud Providers ,然后单击 Amazon Web Services 旁边的 plug symbol 。
Step 11 − Now go back to Docker Cloud, select Cloud Providers, and click the plug symbol next to Amazon Web Services.
输入 arn 角色,然后单击 Save 按钮。
Enter the arn role and click the Save button.
保存后,与 AWS 的集成将完成。
Once saved, the integration with AWS would be complete.
Setting Up Nodes
与 AWS 的集成完成后,下一步是设置节点。转至 Docker Cloud 中的“节点”部分。请注意,首先设置节点将自动设置节点集群。
Once the integration with AWS is complete, the next step is to setup a node. Go to the Nodes section in Docker Cloud. Note that the setting up of nodes will automatically setup a node cluster first.
Step 1 − 转至 Docker Cloud 中的“节点”部分。
Step 1 − Go to the Nodes section in Docker Cloud.
Step 2 − 接下来,您可以给出将在 AWS 中设置的节点的详细信息。
Step 2 − Next, you can give the details of the nodes which will be setup in AWS.
然后,您可以单击“启动节点集群”,该集群将显示在屏幕底部。一旦节点部署完毕,您将收到节点集群屏幕中的通知。
You can then click the Launch Node cluster which will be present at the bottom of the screen. Once the node is deployed, you will get the notification in the Node Cluster screen.
Deploying a Service
部署节点后,下一步是部署服务。为此,我们需要执行以下步骤。
The next step after deploying a node is to deploy a service. To do this, we need to perform the following steps.
Step 1 - 转到 Docker Cloud 中的 Services Section 。单击 Create 按钮
Step 1 − Go to the Services Section in Docker Cloud. Click the Create button
Step 2 - 选择所需的的服务。在我们的示例中,我们选择 mongo 。
Step 2 − Choose the Service which is required. In our case, let’s choose mongo.
Step 3 - 在下一屏幕中,选择 Create & Deploy 选项。这会开始在你的节点集群上部署 Mongo 容器。
Step 3 − On the next screen, choose the Create & Deploy option. This will start deploying the Mongo container on your node cluster.
部署后,你将能够看到容器已处于正在运行的状态。
Once deployed, you will be able to see the container in a running state.