https://docs.docker.com/get-started/part3/#introduction
Introduction
In part 3, we scale our application and enable load-balancing. To do this, we must go one level up in the hierarchy of a distributed application: the service.
part3,我们将拓展应用,支持负载均衡。做到这点,我们必须使用更上级分布式应用层:the service
About services
In a distributed application, different pieces of the app are called “services.” For example, if you imagine a video sharing site, it probably includes a service for storing application data in a database, a service for video transcoding in the background after a user uploads something, a service for the front-end, and so on.
分布式应用程序中,不同的app部分称为services。如,你设想一个视频分享网站,它可能包含数据存储服务,用户上传视频转码服务,前端服务等等。
Services are really just “containers in production.” A service only runs one image, but it codifies the way that image runs—what ports it should use, how many replicas of the container should run so the service has the capacity it needs, and so on. Scaling a service changes the number of container instances running that piece of software, assigning more computing resources to the service in the process.
Services 其实是生产中containers。一个service只运行一个镜像,但定义了镜像的运行方式--端口的使用,服务需要的container副本数,等等。拓展一个服务只是改变运行软件container实例的个数,进程中指定更多的计算资源指向服务。
Luckily it’s very easy to define, run, and scale services with the Docker platform -- just write a docker-compose.yml
file.
幸运的是通过Docker平台可以非常简单的定义,运行,拓展服务--只需定义一个docker-compose.yml文件。
Your first docker-compose.yml
file
A docker-compose.yml
file is a YAML file that defines how Docker containers should behave in production.
docker-compose.yml是
YAML 文件定义了Docker containers在生产中的行为。
Save this file as docker-compose.yml
wherever you want. Be sure you have pushed the image you created in Part 2 to a registry, and update this