Docker icon

Docker

Interact with Docker via Portainer API

Overview

This node allows users to create Docker images by interacting with the Docker API through a Portainer endpoint. It supports importing images from various sources, pulling images by name or digest, and applying Dockerfile instructions during image creation. This is useful in automation workflows where container images need to be managed programmatically, such as CI/CD pipelines, automated deployments, or image repository management.

Practical examples:

  • Importing a Docker image from a URL or local content.
  • Pulling a specific tagged image from a repository.
  • Creating a new image with custom environment variables or entrypoints applied.

Properties

Name Meaning
EndpointID Name or ID The Portainer endpoint to use for accessing the Docker API. Choose from a list of available endpoints or specify an ID directly.
Input Image The raw image content to import when the fromSrc parameter is set to -, indicating the image data is provided in the request body.
Additional Fields A collection of optional parameters to customize the image creation:
- From Image Name of the image to pull. If it includes a tag or digest, special rules apply (tag precedence, digest usage).
- From Src Source to import the image from. Can be a URL or - to read from the request body. Only valid when importing an image.
- Repo Repository name assigned to the imported image, may include a tag. Only valid when importing.
- Tag Tag or digest for the image. If empty when pulling, all tags are pulled.
- Message Commit message for the imported image.
- X Registry Auth Base64url-encoded authentication configuration for private registries.
- Changes JSON array of Dockerfile instructions to apply to the created image (e.g., ENV DEBUG=true). Supported instructions include CMD, ENTRYPOINT, ENV, EXPOSE, ONBUILD, USER, VOLUME, WORKDIR. Instructions should be URI component encoded.
- Platform Target platform in the format os[/arch[/variant]]. Used to select or specify the OS/architecture for pulling or importing images. Defaults to host's native platform if not specified.

Output

The node outputs JSON data representing the response from the Docker API after the image creation operation. This typically includes details about the created or imported image, such as its ID, status messages, or any warnings.

If the image content is provided via the Input Image property (when fromSrc is -), the node sends this binary data in the request body but does not output binary data itself.

Dependencies

  • Requires a Portainer API endpoint configured with appropriate access rights.
  • Needs an API key or token credential for authenticating with the Portainer API.
  • The node depends on the Portainer API being accessible at the specified URL and endpoint.

Troubleshooting

  • Common issues:

    • Invalid or missing endpoint ID: Ensure the selected endpoint exists and is reachable.
    • Authentication failures: Verify that the API key/token is correct and has sufficient permissions.
    • Incorrect image source or tag: Double-check the fromImage, fromSrc, and tag values for typos or invalid references.
    • Unsupported Dockerfile instructions in changes: Make sure instructions are among the supported list and properly URI encoded.
  • Error messages:

    • HTTP 401 Unauthorized: Check API credentials.
    • HTTP 404 Not Found: The specified endpoint or image does not exist.
    • HTTP 400 Bad Request: Likely due to malformed parameters; review input fields carefully.
    • Errors related to image import or pull usually indicate network issues or incorrect source URLs.

Links and References

Discussion