docker swarm: find all services using a certain secret

If you find yourself in a situation like us, wanting to know how many and which services in a docker swarm are using a specific secret, this might help you:

$ docker service ls | awk '{print $1}' | xargs docker service inspect | jq '.[].Spec.Name + " " + .[].Spec.TaskTemplate.ContainerSpec.Secrets[]?.SecretName' | grep -i <your-secret-name>