We want to run a task in a docker service using the one-off global-job mode.
docker service create --name ping-google-global --mode=global-job bash ping -c 5 google.com
This works but has two shortcomings:
- when we want to run this again (via the same command) we get an error:
Error response from daemon: rpc error: code = AlreadyExists desc = name conflicts with an
existing object: service ping-google-global already exists
- we cannot immediately see the output of the command as it is only available via the docer service logs
My questions:
- How can we run the service several times? Will we have to remove it via
docker service rm ping-google-global
or is there a canonical way to make thesemode=global-job
"executable" several times? - Generally: How can we make the output of the command executed immediately available (to stdout instead to an internal container log).