Launching a service

Rather than launching containers using the docker container run command you need to create a service A service defines a task which the manager then passes to one of the workers and then a container is launched.

Let's launch a simple service called cluster which uses the image we looked at in Chapter 2, Launching Applications Using Docker:

docker service create --name cluster -p:80:80/tcp russmckendrick/cluster

That's it, we should now have a single container running on one of our three nodes. To check that the service is running and get a little more information about the service, run the following commands:

docker service ls
docker service inspect cluster --pretty

Now that we have confirmed that our service is running, you ...

Get Docker Bootcamp now with O’Reilly online learning.

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