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
The node integrates with the Portainer API to manage Docker containers and related resources. Specifically, the Container - Get Logs operation retrieves logs from a specified Docker container within a given environment (endpoint). This is useful for monitoring container output, debugging issues, or auditing container activity.
Typical use cases include:
- Fetching real-time or historical logs of a container to diagnose problems.
- Collecting logs for audit or compliance purposes.
- Integrating container logs into broader monitoring or alerting workflows.
For example, you might use this node to get the last 100 lines of logs including both stdout and stderr from a web server container running in your Docker environment managed by Portainer.
Properties
| Name | Meaning |
|---|---|
| Environment ID | The ID of the Portainer environment/endpoint where the container runs. |
| Container ID | The unique identifier of the Docker container whose logs are to be retrieved. |
| Include Stdout | Whether to include standard output (stdout) logs. |
| Include Stderr | Whether to include standard error (stderr) logs. |
| Tail Lines | Number of lines from the end of the logs to retrieve, or "all" to fetch the entire log. |
| Timestamps | Whether to include timestamps in each log line. |
Output
The node outputs JSON data containing the logs retrieved from the specified container. The logs are returned as a plain text string combining the requested streams (stdout and/or stderr), optionally including timestamps.
There is no binary data output for this operation.
Example output structure:
{
"logs": "<string containing the container logs>"
}
The exact format of the logs string depends on the container's logging driver and the options selected (e.g., inclusion of timestamps).
Dependencies
- Requires an active connection to a Portainer instance with API access.
- Needs an API key credential configured in n8n to authenticate requests to the Portainer API.
- The Portainer environment (endpoint) must be accessible and contain the target container.
Troubleshooting
- Invalid Environment or Container ID: If the environment ID or container ID is incorrect or does not exist, the API will return an error. Verify IDs are correct and that the container is running or exists in the specified environment.
- Insufficient Permissions: Ensure the API key used has permissions to access container logs.
- Empty Logs: If logs are empty, check if the container has produced any output or if the log driver is configured properly.
- Timeouts or Connectivity Issues: Network issues between n8n and the Portainer instance can cause failures. Confirm network connectivity and API availability.
- Large Log Size: Requesting all logs for very large containers may result in performance issues or timeouts. Use the "Tail Lines" property to limit the amount of data fetched.
Links and References
This summary is based on static analysis of the provided source code and property definitions without runtime execution.