A service is a group of containers with the same image:tag
.
It makes it easy to scale your application (i.e. you just increase the number of containers in the service).
To create a new service use
docker service create
Note – this must be run on a Swarm manager.
e.g.
docker service create -d --name pinger --replicas 2 --network ubernet alpine sleep 1d
List with:
docker service ls
Check which nodes they’re on with:
docker service ps pinger
and, switching to that node, we can check the network with:
docker network inspect ubernet
which shows the service under Containers
.
Switching to the second replica we should see the task by doing a:
docker container ls