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, for the Container - Stop operation, it allows you to stop a running Docker container on a specified environment (endpoint) managed by Portainer.

Stopping a container is useful when you want to gracefully shut down a running containerized application or service without deleting it. This can be part of maintenance workflows, scaling down services, or preparing containers for updates.

Practical example:
You have a web application running inside a Docker container managed via Portainer. You want to temporarily stop this container during off-peak hours to save resources. Using this node's Container Stop operation, you specify the environment and container ID, optionally set a timeout, and stop the container safely.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the container runs.
Container ID The unique identifier of the container to stop.
Timeout Number of seconds to wait before forcefully stopping the container (default: 10 seconds).

Output

The node outputs JSON data representing the response from the Portainer API after attempting to stop the container. Typically, this will include status information about the stop request. The exact structure depends on the Portainer API response but generally confirms whether the stop command was accepted or if there were errors.

No binary data output is involved in this operation.

Dependencies

  • Requires an active Portainer instance accessible via its API.
  • Requires an API key credential configured in n8n to authenticate requests to the Portainer API.
  • The node uses the base URL and API key from the configured credentials to send HTTP POST requests to the endpoint /endpoints/{environmentId}/docker/containers/{containerId}/stop.

Troubleshooting

  • Common issues:

    • Invalid or missing Environment ID or Container ID will cause the API call to fail.
    • Insufficient permissions or invalid API key may result in authentication errors.
    • If the container is already stopped, the API might return an error or no-op response.
    • Network connectivity issues between n8n and the Portainer server can cause request failures.
  • Error messages and resolutions:

    • 401 Unauthorized: Check that the API key credential is correct and has sufficient permissions.
    • 404 Not Found: Verify that the Environment ID and Container ID are correct and that the container exists.
    • Timeout errors: Increase the timeout property or check network stability.
    • 400 Bad Request: Ensure all required parameters are provided and valid.

Links and References


This summary covers the Container Stop operation of the Portainer node based on static analysis of the source code and provided properties.

Discussion