Docker icon

Docker

Interact with Docker via Portainer API

Actions107

Overview

This node allows users to interact with Docker containers through the Portainer API. Specifically, the "Container List" operation fetches a list of Docker containers from a specified Docker endpoint managed by Portainer. It supports filtering and customization options such as returning all containers (not just running ones), limiting the number of results, including container size information, and applying complex filters based on container attributes.

Common scenarios for this node include:

  • Monitoring Docker containers across multiple endpoints.
  • Automating container management workflows by retrieving container states and metadata.
  • Integrating container data into broader automation pipelines, e.g., triggering actions based on container status or labels.

Practical example:

  • Retrieve all running containers on a specific Docker endpoint to generate a report.
  • Fetch paused containers filtered by label to trigger notifications or maintenance tasks.

Properties

Name Meaning
EndpointID Name or ID The identifier of the Docker endpoint to query. You can select from a list of available endpoints or specify an ID using an expression. This determines which Docker environment the node will interact with.
Additional Fields A collection of optional parameters to customize the container listing:
- All: Boolean flag to return all containers, including stopped ones. Default behavior returns only running containers.
- Limit: Number specifying how many of the most recently created containers to return, including non-running ones.
- Size: Boolean flag to include container size details (SizeRw and SizeRootFs) in the response.
- Filters: JSON string representing filters to apply on the container list. Filters support various keys like status, label, name, health, etc., allowing fine-grained selection of containers.

Output

The node outputs a JSON array where each item represents a Docker container matching the query criteria. Each container object includes standard Docker container properties such as container ID, names, image, state, status, and optionally size fields if requested.

If the "Size" option is enabled, additional fields SizeRw and SizeRootFs are included, indicating the writable layer size and the total size of the container's root filesystem respectively.

No binary data output is produced by this node.

Dependencies

  • Requires access to a Portainer API instance managing Docker endpoints.
  • An API key credential or equivalent authentication token for the Portainer API must be configured in n8n credentials.
  • The node dynamically loads available Docker endpoints from Portainer to populate the endpoint selection property.

Troubleshooting

  • Authentication errors: Ensure that the Portainer API credentials are correctly set up and have sufficient permissions to access the specified endpoint.
  • Empty container list: Verify that the selected endpoint is correct and that containers exist matching the filter criteria. If using filters, ensure the JSON syntax is valid and filter keys/values are supported.
  • Invalid filter format: The filters property expects a JSON-encoded string representing a map of string arrays. Malformed JSON or unsupported filter keys may cause errors or empty results.
  • API connectivity issues: Confirm network connectivity to the Portainer API URL and that the endpoint ID exists and is accessible.

Links and References

Discussion