Docker icon

Docker

Interact with Docker via Portainer API

Overview

This node allows users to retrieve logs from Docker containers managed via the Portainer API. It is useful for monitoring container output, debugging issues, or auditing container activity by fetching standard output and error logs. Typical use cases include:

  • Viewing real-time logs of a running container.
  • Fetching historical logs within a specific time range.
  • Filtering logs to only show stdout or stderr.
  • Tailoring log output size to recent lines or full logs.

For example, a DevOps engineer might use this node to automatically collect logs from a container after deployment to verify successful startup or diagnose errors.

Properties

Name Meaning
EndpointID Name or ID The Portainer endpoint identifier used to access the Docker environment. Can be selected from a list or specified via an expression.
Id The ID or name of the Docker container whose logs are to be retrieved.
Additional Fields Optional parameters to customize the logs retrieval:
- Follow Boolean flag to keep the connection open and stream logs continuously after initial retrieval.
- Stdout Boolean flag to include logs from the container's standard output stream.
- Stderr Boolean flag to include logs from the container's standard error stream.
- Since UNIX timestamp to return logs only since this time (filters out older logs).
- Until UNIX timestamp to return logs only before this time (filters out newer logs).
- Timestamps Boolean flag to prepend timestamps to each log line.
- Tail Number of log lines to return from the end of the logs, or "all" to return all available lines.

Output

The node outputs JSON data containing the logs retrieved from the specified container. The exact structure depends on the Portainer API response but typically includes the raw log text lines. If streaming (Follow) is enabled, the node may output logs incrementally as they arrive.

No binary data output is indicated.

Dependencies

  • Requires a Portainer API endpoint with Docker access.
  • Needs an API key credential configured in n8n to authenticate requests to the Portainer API.
  • The node uses the Portainer API base URL and endpoint ID to construct requests.

Troubleshooting

  • Invalid Endpoint or Container ID: Ensure the endpoint ID and container ID/name are correct and accessible via the Portainer API.
  • Authentication Errors: Verify that the API key credential is valid and has sufficient permissions.
  • Empty Logs: Check if the container is running and producing logs; also verify the since and until timestamps do not exclude all logs.
  • Connection Timeout with Follow Enabled: Streaming logs requires a persistent connection; network issues or API limits may cause disconnections.
  • Incorrect Property Types: For example, tail should be an integer or "all"; invalid values may cause errors.

Links and References

Discussion