Docker icon

Docker

Interact with Docker via Portainer API

Actions107

Overview

This node allows you to create Docker containers by interacting with the Portainer API. It is useful in scenarios where you want to automate container deployment and management within your infrastructure using n8n workflows. For example, you can use this node to programmatically spin up new containers based on specific configurations or dynamically create containers as part of a CI/CD pipeline.

Properties

Name Meaning
EndpointID Name or ID The identifier of the Portainer endpoint to use for accessing the Docker API. You can select from a list of available endpoints or specify an ID via expression. This determines which Docker environment the container will be created in.
Body The JSON string representing the container configuration to create. This should include all necessary container settings as per the Docker API specification.
Additional Fields Optional extra parameters:
- Name: Assigns a specific name to the container. Must match the regex pattern /?[a-zA-Z0-9][a-zA-Z0-9_.-]+.
- Platform: Specifies the platform in the format os[/arch[/variant]] used for image lookup. If set, the daemon checks if the image exists locally for that platform; otherwise, it uses the host's native platform.

Output

The node outputs JSON data representing the response from the Portainer API after attempting to create the container. This typically includes details about the newly created container such as its ID, warnings (if any), and other metadata returned by the Docker API through Portainer.

No binary data output is produced by this node.

Dependencies

  • Requires access to a Portainer API endpoint.
  • Requires an API key credential for authenticating with the Portainer API.
  • The node depends on the Portainer API being accessible at the URL specified in the credentials.
  • Uses the Portainer API /api/endpoints to load available endpoints dynamically.

Troubleshooting

  • Invalid EndpointID: If the selected endpoint ID does not exist or is unreachable, the node will fail to connect. Verify the endpoint ID and network connectivity.
  • Malformed Body JSON: The "Body" property must be a valid JSON string representing the container configuration. Invalid JSON will cause request failures.
  • Container Name Validation: If specifying a container name, ensure it matches the required regex pattern; otherwise, the API will reject the request.
  • Platform Mismatch Warning: If the specified platform does not match the host or local image cache, the container may still be created but with a warning. Review warnings in the output to ensure expected behavior.
  • Authentication Errors: Ensure the API key credential is valid and has sufficient permissions to create containers on the target endpoint.

Links and References

Discussion