Services and tasks

Along with the new orchestration engine, Docker introduced the new abstraction of services and tasks in version 1.12. A service may consist of many instances of a task. We call each instance a replica. Each instance of a task runs on a Docker node in the form of a container.

A service can be created using the following command:

$ docker service create \   --replicas 3 \   --name web \   -p 80:80 \   --constraint node.role==worker \   nginx

This web service consists of three tasks, specified with --replicas. These tasks are submitted by the orchestration engine to run on selected nodes. The service's name, web, can be resolved using a virtual IP address. Other services on the same network, in this case maybe a reverse proxy service, ...

Get Docker for Serverless Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.