Actions88
- Container Actions
- Container List
- Container Create
- Container Inspect
- Container Top
- Container Logs
- Container Changes
- Container Export
- Container Stats
- Container Resize
- Container Start
- Container Stop
- Container Restart
- Container Kill
- Container Update
- Container Rename
- Container Pause
- Container Unpause
- Container Attach
- Container Attach Websocket
- Container Wait
- Container Delete
- Container Archive Info
- Container Archive
- Put Container Archive
- Container Prune
- Image Actions
- Network Actions
- Volume Actions
- Swarm Actions
- Node Actions
- Secret Actions
- System Actions
- Exec Actions
- Service Actions
- Task Actions
Overview
This node allows users to update a Docker service via the Portainer API. It is useful in scenarios where you need to modify the configuration or deployment parameters of an existing Docker service managed through Portainer. For example, you might want to update the image version, environment variables, or resource limits of a running service without recreating it from scratch.
Typical use cases include:
- Automating updates to microservices in a Docker Swarm cluster.
- Integrating service updates into CI/CD pipelines.
- Managing service rollbacks or applying new configurations programmatically.
Properties
| Name | Meaning |
|---|---|
| EndpointID Name or ID | The identifier of the Portainer endpoint where the Docker service resides. You can select from a list of available endpoints or specify an ID using an expression. |
| Id | The ID or name of the Docker service you want to update. |
| Version | The current version number of the service object being updated. This is required to prevent conflicting writes. You must provide the version as it exists before the update. |
| Body | The JSON string representing the new service specification to apply. This contains the updated configuration for the service. |
| Additional Fields | Optional extra parameters: - Registry Auth From: Specifies where to find registry authorization credentials if the X-Registry-Auth header is not provided. Options: "Spec" or "Previous Spec".- Rollback: Set to "previous" to rollback the service to its previous spec, ignoring the supplied body.- X Registry Auth: A base64url-encoded authentication string for pulling images from private registries. |
Output
The node outputs the JSON response returned by the Portainer API after attempting to update the service. This typically includes details about the updated service or confirmation of the update operation.
If the update involves binary data (not indicated here), it would be summarized accordingly, but this node primarily deals with JSON data.
Dependencies
- Requires access to a Portainer instance with the API enabled.
- Needs an API key or token credential configured in n8n to authenticate requests to Portainer.
- The node dynamically loads available endpoints from Portainer to populate the "EndpointID" property.
- The base URL and authentication are derived from the configured credentials.
Troubleshooting
- Version Mismatch Error: If the version number provided does not match the current service version, the API will reject the update to avoid conflicts. To fix this, fetch the latest service version before updating.
- Invalid Service ID: Providing an incorrect or non-existent service ID will cause errors. Verify the service ID or name is correct.
- Authentication Failures: Ensure that the API key/token is valid and has sufficient permissions to update services.
- Malformed Body: The body must be a valid JSON string representing the service spec. Invalid JSON or missing required fields will cause the request to fail.
- Rollback Usage: When using the rollback parameter, the body is ignored. Make sure to set rollback only when intending to revert to the previous spec.