Docker Community Forums

Share and learn in the Docker community.

How to pass a command to all running containers in Swarm


I am running docker swarm using below version, my current setup is 3 managers and 3 workers. I am using Varnish for caching, purge and proxy on my internal site. I am currently running 3 Varnish containers using docker services and it’s spread across my swarm. We hit all our docker swarm service through DNS URL which we configured.

If I want to send a command to all 3 containers to warm up the Varnish or Purge the cache in Varnish have to do it manually on the service to see all 3 containers are hit.

Just wondering is there a way we can pass a command that will hit all 3 running Varnish containers and clear the cache or warm up the content I am looking after.

Docker Version:- Docker version 19.03.5, build 633a0ea