In my last article, about Windows Containers, I’ve shown you how to configure a Swarm Cluster made out of two Container Hosts.
Today, I’ll show how to create Containers on a Swarm Cluster which is a bit different than deploying them on a Windows Container host.
Once we move to a Swarm Cluster the terminology of containers is changing from Deploying Containers to Services.
In swarm mode, Containers are Services and a service is a container.
To create the most basic Service on a swarm Container I’ll use the command below:
Docker service create microsoft/nanoserver-insider
We can easily create multiple services in the same way we create containers on a Container host.
To view all running services on a swarm cluster I’ll run the cmdlet
Docker service list
To create a more advanced service with the networking configured and load balancing I’ll use:
Docker service create --name webapp -endpoint-mode=dnsrr --network=swarmnet microsoft/nanoserver-insider
Docker service ls
With Swarm, we can easily scale up our application using the command below which will create 4 containers across the cluster
Docker service scale webapp=4
docker service ps webapp
Docker swarm gives the option to load balance a service using DNS Round Robin using the parameter below:
Note: We can also use External load balancer using published ports, if you are using External Load Balancer we need to use the Publish switch and expose the endpoints
Creating Services on a Windows Containers Swarm Cluster is similar to deploying containers a docker host.
Once you get used to the new commands, everything is the same and easier because we have the option to load balanced the containers and protect them using HA.