0

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:

  1. 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
  1. we cannot immediately see the output of the command as it is only available via the docer service logs

My questions:

  1. 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 these mode=global-job "executable" several times?
  2. Generally: How can we make the output of the command executed immediately available (to stdout instead to an internal container log).
Alexander Presber
  • 6,429
  • 2
  • 37
  • 66

1 Answers1

1
  1. You can either remove the old service or update it. If you want to ensure that it will be run again, even if its config didn't change then you need to update it with --force.

  2. Use docker service logs ping-google-global in a subshell.

Kamil Gwóźdź
  • 777
  • 5
  • 11