Docker icon

Docker

Interact with Docker via Portainer API

Overview

This node allows you to execute commands inside a Docker container by interacting with the Portainer API. It is useful for scenarios where you need to run shell commands or scripts within a running container without directly accessing the host machine or using Docker CLI. For example, you might use this node to inspect container internals, trigger maintenance scripts, or gather runtime information dynamically.

Properties

Name Meaning
EndpointID Name or ID The Portainer endpoint to connect to. Choose from a list of available endpoints or specify an ID via expression. This determines which Docker environment the command will be executed in.
Id The ID or name of the target Docker container where the command will be executed.
Exec Config The execution configuration as a JSON string. This defines the command and options for the exec operation inside the container.

Output

The node outputs JSON data representing the result of the exec command run inside the specified container. This typically includes the command output, status, and any relevant metadata returned by the Portainer API. There is no indication that binary data is returned.

Dependencies

  • Requires access to a Portainer API instance.
  • Needs an API key or token credential configured in n8n to authenticate requests to the Portainer API.
  • The node uses the Portainer API endpoint /api/endpoints/{endpointId}/docker to perform Docker operations remotely.

Troubleshooting

  • Common issues:

    • Invalid or missing endpointId: Ensure the endpoint exists and is accessible.
    • Incorrect container id: Verify the container ID or name is correct and the container is running.
    • Malformed execConfig: The exec configuration must be valid JSON describing the command and parameters; otherwise, the API call will fail.
    • Authentication errors: Confirm the API credentials are valid and have sufficient permissions.
  • Error messages:

    • "Unauthorized" or "Authentication failed": Check API credentials.
    • "Container not found": Verify the container ID/name.
    • "Bad request" or "Invalid exec config": Validate the JSON structure of the exec configuration.

Links and References

Discussion