O'Reilly logo

Mastering Docker - Third Edition by Scott Gallagher, Russ McKendrick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Services

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required