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 - Exec operation allows you to execute a command inside a running Docker container managed by Portainer.

Typical use cases include:

  • Running shell commands or scripts inside a container without needing direct SSH access.
  • Debugging or inspecting container internals dynamically.
  • Automating container management workflows that require executing commands inside containers.

For example, you could run /bin/sh or any other executable inside a container to check logs, modify files, or trigger processes.

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 in which the command will be executed.
Exec Command The command string to execute inside the container (e.g., /bin/sh, ls -la).
TTY Boolean flag indicating whether to allocate a pseudo-TTY for the command execution.

Output

The node outputs JSON data representing the result of the executed command inside the container. This typically includes the standard output and standard error streams captured from the command execution.

If the command produces binary data, it would be included in the output accordingly, but this node primarily deals with textual command execution results.

Dependencies

  • Requires an active Portainer instance accessible via its API.
  • Needs an API key credential configured in n8n to authenticate requests to the Portainer API.
  • The node uses the Portainer API endpoint corresponding to the specified environment ID.

Troubleshooting

  • Invalid Environment or Container ID: If the provided environment or container ID does not exist or is incorrect, the API call will fail. Verify IDs are correct and the container is running.
  • Command Execution Failure: If the exec command is invalid or fails inside the container, the output may contain error messages. Ensure the command syntax is correct and the container has the necessary binaries.
  • Permission Issues: The API key used must have sufficient permissions to execute commands inside containers.
  • TTY Allocation Problems: Setting TTY to true when the container or command does not support it might cause errors. Try toggling the TTY option if issues arise.

Links and References

Discussion