Actions72
- Image Actions
- Network Actions
- Node Actions
- Registry Actions
- Secret Actions
- Service Actions
- Stack Actions
- Team Actions
- Template Actions
- User Actions
- Volume Actions
- Webhook Actions
- Config Actions
- Container Actions
- Edge Group Actions
- Edge Stack Actions
Overview
This node integrates with the Portainer API to manage Docker stacks. Specifically, the Stack - Delete operation allows users to delete a Docker stack from a specified environment (endpoint) in Portainer. This is useful for automating cleanup or removal of Docker Compose stacks managed via Portainer.
Typical use cases include:
- Removing outdated or unused Docker stacks programmatically.
- Automating infrastructure teardown in CI/CD pipelines.
- Managing Docker environments remotely through Portainer's API without manual intervention.
Example: You have a stack deployed on a Docker environment managed by Portainer and want to delete it automatically when a project is finished or during resource cleanup.
Properties
| Name | Meaning |
|---|---|
| Environment ID | The ID of the Portainer environment/endpoint where the stack resides. |
| Stack ID | The unique identifier of the stack to be deleted. |
| Force Delete | Boolean flag indicating whether to force deletion even if the stack is currently in use. |
Output
The node outputs the JSON response returned by the Portainer API after attempting to delete the stack. Typically, this will be an empty object or confirmation of deletion. No binary data is output.
The json output field contains the API response which can be used downstream to confirm success or handle errors.
Dependencies
- Requires a valid Portainer API key credential configured in n8n.
- Needs the base URL of the Portainer instance.
- The node sends authenticated HTTP DELETE requests to the Portainer API endpoint
/stacks/{stackId}with query parameterendpointIdset to the environment ID.
Troubleshooting
Common issues:
- Invalid or missing Environment ID or Stack ID 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 in use without setting "Force Delete" may cause failure.
Error messages:
- 404 Not Found: The specified stack or environment does not exist. Verify IDs.
- 401 Unauthorized: API key is invalid or lacks required permissions.
- 409 Conflict: Stack is in use and cannot be deleted unless "Force Delete" is enabled.
Resolutions:
- Double-check input IDs for correctness.
- Ensure the API key has sufficient privileges.
- Use the "Force Delete" option if you want to forcibly remove the stack despite usage.