Service

Liste des services

sudo docker service ls

ID NAME MODE REPLICAS IMAGE PORTS
o7cygkcijiqa www replicated 3/3 nginx:latest *:8080->80/tcp

Créer un service

sudo docker service create [OPTION] <NAME> [COMMAND] [ARG]

# sudo docker service create --name www -p 8080:80 --replicas 3 nginx
o7cygkcijiqawfeomwc8mjgef
overall progress: 3 out of 3 tasks
1/3: running [==================================================>]
2/3: running [==================================================>]
3/3: running [==================================================>]
verify: Service converged

Vérification du service créer

# sudo docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
o7cygkcijiqa www replicated 3/3 nginx:latest *:8080->80/tcp

Supprimer un service

sudo docker service rm <NAME>

<NAME>
www

Liste des taches d'un service

sudo docker service ps <NAME>

ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
wzv5ttpp1qzj www.1 nginx:latest node2 Running Running 4 minutes ago
59izj8vvey2u www.2 nginx:latest node4 Running Running 4 minutes ago
xe6qiv30nazy www.3 nginx:latest node1 Running Running 4 minutes ago

Modifier le nombre de réplica d'un service

sudo docker service scale <NAME>=[NB SCALE]

www scaled to 1
overall progress: 1 out of 1 tasks
1/1: running [==================================================>]
verify: Service converged

Vérification de la prise en compte de la commande scale

# sudo docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
o7cygkcijiqa www replicated 1/1 nginx:latest *:8080->80/tcp