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 on a specified Portainer environment (endpoint). This is useful for running shell commands or scripts directly within a container without needing direct access to the host machine.

Common scenarios include:

  • Debugging or inspecting a running container by executing shell commands.
  • Running maintenance or administrative commands inside containers.
  • Automating container management workflows that require command execution inside containers.

Example: You can run /bin/sh or any other shell command inside a container to check logs, modify files, or trigger processes dynamically.

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 output JSON contains the response from the Portainer API after executing the command inside the container. Typically, this includes the command's standard output and error streams as returned by the Docker exec API.

If the node supports binary data output (not explicitly shown here), it would represent any binary stream resulting from the command execution, but this operation primarily deals with textual command execution results.

Dependencies

  • Requires a valid connection to a Portainer instance via its API.
  • Needs an API key credential configured in n8n to authenticate requests to the Portainer API.
  • The target Docker environment (endpoint) must be accessible and properly registered in Portainer.
  • The container must be running and accessible in the specified environment.

Troubleshooting

  • Invalid Environment ID or Container ID: Ensure the provided IDs correspond to existing and accessible environments and containers in Portainer.
  • Command Execution Fails: Verify the command syntax and availability inside the container. Some containers may not have shells like /bin/sh.
  • Permission Denied Errors: The API key used must have sufficient permissions to execute commands inside containers.
  • TTY Allocation Issues: If TTY is enabled but the container does not support it, command execution might fail or behave unexpectedly. Try disabling TTY if issues arise.
  • Network or Connectivity Problems: Confirm that n8n can reach the Portainer API endpoint and that the environment is online.

Links and References

Discussion