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 will be able to open your browser and enter the IP address of one of your three nodes (which you can get by running docker-machine ls
).One of the features of Docker Swarm is it's routing mesh.
A routing mesh? When we exposed the port using the -p:80...