Services are the most basic and straightforward way to run containers using a Docker swarm. They allow you to execute multiple replica containers across all nodes in the Swarm cluster.
In this lab, you will have the opportunity to work with Docker services. You will practice scaling services by changing the number of replicas for an existing service. You will also have the opportunity to create a new service and run it in the cluster.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Scale the products-fruit service to 5 replicas.
Scale the service.
docker service update --replicas 5 products-fruit
You can also do it this way (both do the same thing):
docker service scale products-fruit=5
- Create the products-vegetables service.
Create the
products-vegetables
service.docker service create --name products-vegetables -p 8081:80 --replicas 3 linuxacademycontent/vegetable-service:1.0.0
Verify that the service is working.
curl localhost:8081
You should see some JSON data containing a list of vegetables.