Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker Swarm services. Specifically, the Service - Update operation allows users to update an existing Docker Swarm service's configuration, such as changing the Docker image or environment variables used by the service.

Typical use cases include:

  • Updating a running service to use a new Docker image version.
  • Modifying environment variables for a service without redeploying manually.
  • Automating service updates in CI/CD pipelines or infrastructure automation workflows.

For example, you might update a web service to use nginx:1.21 instead of nginx:latest, or inject new environment variables to change runtime behavior dynamically.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the Docker service is managed.
Service ID The unique identifier of the Docker Swarm service to update.
Image The Docker image (including tag) to be used by the service after update (e.g., nginx:latest).
Environment Variables A collection of environment variables to set on the service, each with a name and a value.
Version The current version number of the service object; required for concurrency control during update.

Output

The node outputs JSON data representing the response from the Portainer API after updating the service. This typically includes metadata about the updated service, such as its ID, version, and updated configuration details.

No binary data output is involved in this operation.

Dependencies

  • Requires a valid connection to a Portainer instance via its API.
  • An API key credential must be configured in n8n to authenticate requests to Portainer.
  • The Portainer API base URL and API key are expected to be provided through credentials.

Troubleshooting

  • Version Mismatch Error: If the version parameter does not match the current service version in Portainer, the update will fail due to concurrency control. To fix, retrieve the latest service version before updating.
  • Invalid Service ID: Providing a non-existent or incorrect service ID will result in a "not found" error. Verify the service ID is correct.
  • Authentication Errors: Ensure the API key credential is valid and has sufficient permissions to update services.
  • Malformed Environment Variables: Environment variables must be provided as an array of objects with name and value. Incorrect formatting may cause request failures.
  • Network Issues: Connectivity problems to the Portainer API endpoint will prevent updates. Check network access and base URL correctness.

Links and References


This summary is based on static analysis of the node's source code and property definitions related to the Service resource's Update operation.

Discussion