Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker stacks. Specifically, the Delete Stack operation allows users to delete a Docker Compose stack managed by Portainer. This is useful for automating cleanup or removal of application stacks in Docker environments managed via Portainer.

Typical use cases include:

  • Automatically removing outdated or unused stacks as part of CI/CD pipelines.
  • Managing lifecycle of Docker Compose applications programmatically.
  • Cleaning up resources during environment teardown or maintenance.

For example, you can configure this node to delete a specific stack by providing its Stack ID and the Environment (endpoint) ID where it resides.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the stack is deployed.
Stack ID The unique identifier of the stack to be deleted.
Force Delete Whether to force deletion even if the stack is currently in use (boolean: true or false).

Output

The node outputs the JSON response returned by the Portainer API after attempting to delete the specified stack. Typically, this will be an empty object or confirmation of successful deletion. If the deletion fails, the output may contain error details from the API.

No binary data is produced by this operation.

Dependencies

  • Requires a valid Portainer API key credential configured in n8n.
  • The node makes HTTP DELETE requests to the Portainer API endpoint /stacks/{stackId} with query parameter endpointId set to the Environment ID.
  • The base URL and API key must be correctly set in the node credentials to authenticate requests.

Troubleshooting

  • Common issues:

    • Invalid or missing Environment ID or Stack ID parameters will cause the API call to fail.
    • Insufficient permissions or invalid API key may result in authorization errors.
    • Trying to delete a stack that is currently in use without setting "Force Delete" may cause failure.
    • Network connectivity issues to the Portainer server will prevent the request.
  • Error messages:

    • 404 Not Found: The specified stack or environment does not exist. Verify IDs.
    • 401 Unauthorized: API key is invalid or missing. Check credentials.
    • 409 Conflict: Stack is in use and cannot be deleted unless "Force Delete" is enabled.
  • Resolutions:

    • Double-check the Environment ID and Stack ID values.
    • Ensure the API key has sufficient privileges.
    • Enable "Force Delete" if you want to forcibly remove the stack.
    • Confirm network access to the Portainer API endpoint.

Links and References

Discussion