elowy01
4/9/2020 - 9:02 AM

Docker services

# creating a new service:
# --name (we provide a name) 
# 8081:80 --> 8081 is the localhost port we are to use. 
# image name is: linuxacademycontent/vegetable-service:1.0.0
> docker service create --name products-vegetables -p 8081:80 --replicas 3 linuxacademycontent/vegetable-service:1.0.0
# we check that service is working
> curl localhost:8081

# listing the running services:
> docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                                     PORTS
ydsc35zgoe40        products-fruit      replicated          3/3                 linuxacademycontent/fruit-service:1.0.1   *:8080->80/tcp
# scale the service up to a certain number of replicas (2 ways:)
# 1st way:
docker service update --replicas 5 products-fruit
# 2nd way:
docker service scale products-fruit=5