portainer_service_update
Update a Docker Swarm service by changing its image, adjusting replica count, or forcing a task restart. Applies desired changes to the service spec and triggers a rolling update to converge the deployment.
Instructions
Update a Swarm service: change its image, scale it, or force a restart.
Reads the current spec and version, applies the requested changes and submits the spec back (rolling update per the service's UpdateConfig). At least one of image / replicas / force_restart is required. Follow up with portainer_service_wait to know when the rollout converged.
To roll out a new build of the same :latest tag, pass image=
":" without a digest — Swarm resolves the tag to its
current digest at update time. force_restart alone re-creates the
tasks with the image digest already pinned in the spec.
Args:
service_id: Service ID or name
image: New image reference (e.g. "registry.example.com/app:latest")
replicas: New replica count (replicated services only)
force_restart: Re-create all tasks even if the spec is unchanged
(docker service update --force)
registry_id: ID of a Portainer-configured registry whose stored
credentials the nodes should use to pull the image
(auto-detected from the image host when omitted; 0 = none)
endpoint_id: Target endpoint ID (uses default if omitted)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image | No | ||
| replicas | No | ||
| service_id | Yes | ||
| endpoint_id | No | ||
| registry_id | No | ||
| force_restart | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |