https://docs.docker.com/get-started/part4/
准备
Install Docker version 1.13 or higher.
安装Docker 1.13或更高版本。
Get Docker Compose as described in Part 3 prerequisites.
像part3准备部分描述的获取Docker Compose。
Get Docker Machine, which is pre-installed with Docker for Mac and Docker for Windows, but on Linux systems you need to install it directly. On pre Windows 10 systems without Hyper-V, as well as Windows 10 Home, use Docker Toolbox.
获取Docker Machine, Docker for Mac和 Docker for Windows中已预装,linux中你需要进行安装。win10先前版本没有Hyper-V,同win10 home一样,使用Docker Toolbox.
Read the orientation in Part 1.
阅读part1介绍。
Learn how to create containers in Part 2.
学习part2创建containers
Make sure you have published the friendlyhello
image you created bypushing it to a registry. We use that shared image here.
确保上传friendlyhello
镜像至注册中心。我们这里会用到。
Be sure your image works as a deployed container. Run this command, slotting in your info for username
, repo
, and tag
: docker run -p 80:80 username/repo:tag
, then visit http://localhost/
.
确保镜像部署为容器工作。运行命令,将username
, repo
, and tag替换为你自己的信息,然后执行docker run -p 80:80 username/repo:tag命令,访问http://localhost/
.
Have a copy of your docker-compose.yml
from Part 3 handy.
从part3中拿到docker-compose.yml文件。
In part 3, you took an app you wrote in part 2, and defined how it should run in production by turning it into a service, scaling it up 5x in the process.
part3中,你用了part2的app,并且通过其转换为服务,进程中拓展5倍数量定义了其生产环境的运行方式。
Here in part 4, you deploy this application onto a cluster, running it on multiple machines. Multi-container, multi-machine applications are made possible by joining multiple machines into a “Dockerized” cluster called a swarm.
part4,你将进行集群部署,运行多台机器。将多台机器接入“Dockerized”集群称为swarm从而实现了多容器,多机器应用。
A swarm is a group of machines that are running Docker and joined into a cluster. After that has happened, you continue to run the Docker commands you’re used to, but now they are executed on a cluster by a swarm manager. The machines in a swarm can be physical or virtual. After joining a swarm, they are referred to as nodes.
A swarm是一组机器运行着docker且加入了集群。这之后,你像以前执行docker命令,不过现在通过swarm manager在集群上执行。swarm上的机器可以是物理或虚拟的。加入swarm后,它们被称为nodes节点。
Swarm managers can use several strategies to run containers, such as “emptiest node” -- which fills the least utilized machines with containers. Or “global”, which ensures that each machine gets exactly one instance of the specified container. You instruct the swarm manager to use these strategies in the Compose file, just like the one you have already been using.
Swarm managers可以用多种策略运行containers,如 “emptiest node”--会将container填充到最少使用的机器。或“global”,保证每台机器得到指定container的一个实例。你指定swarm manager在Compose file中使用这些策略,像你已经使用过的那样。
Swarm managers are the only machines in a swarm that can execute your commands, or authorize other machines to join the swarm as workers. Workers are just there to provide capacity and do not have the authority to tell any other machine what it can and cannot do.
在一个swarm,Swarm managers是唯一可以执行命令,授权其他机器作为workers加入swarm。Workers 只提供计算能力没有权利去告知其他机器它能做什么不能做什么。
Up until now, you have been using Docker in a single-host mode on your local machine. But Docker also can be switched into swarm mode, and that’s what enables the use of swarms. Enabling swarm mode instantly makes the current machine a swarm manager. From then on, Docker runs the commands you execute on the swarm you’re managing, rather than just on the current machine.
待续。。。