Restart all the services at once

Hi

Can we restart all the services at once in swarm? If yes please let me know the set of commands.

A quick response will be appreciated.

Thanks!

You can update services with the --force option to re-schedule them:
docker service ls -q | xargs -n1 docker service update --force

If you care to see the service names, use this one instead:
docker service ls --format '{{.Name}}' | xargs -n1 docker service update --force

It will iterate over all existing services and forcefully update each one.

Thanks @meyay will try this.

docker service ls -q | xargs -t -n1 docker service update --force
In the above command what are -t and -n1?

docker service ls --format '{{.Name}}' | xargs -n1 docker service update --force
You mean this will show which service is updating?

Your first question: I have no idea where the option -t commes from, I didn’t provide it. For the option -n1 see: http://man7.org/linux/man-pages/man1/xargs.1.html

Your second question: uhm, that’s what I wrote.

Thanks @meyay It worked :slightly_smiling_face:

I found -t in this open issue.

1 Like