Docker · Arazzo Workflow
Docker Roll a Swarm Service Onto a New Image
Version 1.0.0
Read a service's current version, update it to a new image, watch the tasks reconverge, and tail the service logs.
Provider
Workflows
rolling-update-service
Update a running swarm service to a new image using its current version index.
Inspects the service to obtain its current spec and version index, submits an updated spec pinned to that version so a concurrent write is rejected rather than lost, then lists tasks and tails logs to confirm the rollout.
1
inspectService
ServiceInspect
Read the service's current spec and version index. The version index is required by the update call — it is what makes the write conditional on nobody else having changed the service in the meantime.
2
updateService
ServiceUpdate
Submit the updated spec pinned to the version index read above, rolling tasks onto the new image start-first so capacity is never dipped below the target during the update.
3
watchRollout
TaskList
List the service's tasks desired to be running so the caller can watch the new tasks come up and the old ones drain during the rolling update.
4
confirmUpdateState
ServiceInspect
Read the service back to check the update status the swarm reports. A state of "completed" means the rollout landed; "paused" or "rolling_back" means it tripped the failure action.
5
tailServiceLogs
ServiceLogs
Tail the aggregated logs across the service's tasks with timestamps, so a failed rollout can be diagnosed without hunting for individual containers.