The service command is a way of launching containers that take advantage of the Swarm cluster. Let's look at launching a really basic single-container service on our Swarm cluster. To do this, run the following command:

$ docker service create \    --name cluster \    --constraint "node.role == worker" \    -p:80:80/tcp \    russmckendrick/cluster

This will create a service called cluster that consists of a single container with port 80 mapped from the container to the host machine, and it will only be running on nodes that have the role of worker.

Before we look at doing more with the service, we can check whether it worked on our browser. To do this, we will need the IP address of our two worker nodes. First of all, we need to double check ...

Get Mastering Docker - Third Edition now with O’Reilly online learning.

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