Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker containers and other Docker-related resources. Specifically, the Container - Restart operation allows users to restart a running Docker container within a specified environment (endpoint) managed by Portainer.

Typical use cases include:

  • Automatically restarting containers after configuration changes or updates.
  • Recovering containers that have become unresponsive or are in an error state.
  • Managing container lifecycle as part of automated workflows for deployment or maintenance.

For example, you might use this node to restart a web server container after deploying new code or to ensure a container is restarted gracefully with a timeout before forceful termination.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the container is running.
Container ID The unique identifier of the Docker container to be restarted.
Timeout Number of seconds to wait before forcefully stopping the container during restart (default 10 seconds).

Output

The node outputs JSON data representing the response from the Portainer API after attempting to restart the container. This typically includes status information about the restart request but does not return detailed container state.

No binary data output is produced by this operation.

Dependencies

  • Requires a valid connection to a Portainer instance via its API.
  • An API key credential for authenticating requests to the Portainer API must be configured in n8n.
  • The node uses the base URL and API key from the configured credentials to send HTTP POST requests to the Portainer endpoint.

Troubleshooting

  • Invalid Environment ID or Container ID: If these IDs are incorrect or do not exist, the API will return an error indicating the resource was not found. Verify the IDs are correct and correspond to existing resources in Portainer.
  • Timeout Issues: Setting the timeout too low may cause the container to be forcefully stopped prematurely. Adjust the timeout value according to the container's shutdown requirements.
  • Authentication Errors: Ensure the API key credential is valid and has sufficient permissions to perform container operations.
  • Network Connectivity: The node requires network access to the Portainer API endpoint. Check firewall rules and network settings if requests fail.

Common error messages usually come directly from the Portainer API and relate to authorization failures, missing resources, or invalid parameters.

Links and References


This summary focuses on the "Container" resource with the "Restart" operation as requested.

Discussion