Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node integrates with the Portainer API to manage Docker resources programmatically. Specifically, for the Image - Build operation, it allows users to build Docker images from a Dockerfile context directly through Portainer's API. This is useful in CI/CD pipelines or automation workflows where you want to create Docker images dynamically without manually running Docker CLI commands.

Typical use cases include:

  • Automating image builds as part of deployment pipelines.
  • Building custom Docker images from source code archives or tarballs.
  • Integrating Docker image creation into broader container management workflows within n8n.

Example: You can provide a tarball containing your Dockerfile and application source, specify an image tag, and trigger a build on a remote Docker environment managed by Portainer.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the Docker image will be built.
Image Tag The tag to assign to the built Docker image (e.g., "latest", "v1.0").

Output

The node outputs JSON data representing the response from the Portainer API after attempting to build the Docker image. This typically includes build status, logs, or error messages returned by the Docker daemon via Portainer.

If the build is successful, the output JSON may contain details about the created image, such as its ID and tags.

No binary data output is indicated for this operation.

Dependencies

  • Requires a configured Portainer API credential with:
    • Base URL of the Portainer instance.
    • An API key/token for authentication.
  • The Portainer instance must have access to the Docker environment where the image build will occur.
  • The input buildContext should be a tar archive (binary or base64 encoded) containing the Dockerfile and related files, sent with content type application/x-tar.

Troubleshooting

  • Build failures due to invalid Dockerfile or context: Ensure the provided build context tarball contains a valid Dockerfile and all necessary files.
  • Authentication errors: Verify that the API key credential is correct and has sufficient permissions.
  • Incorrect Environment ID: Confirm the environment ID corresponds to a valid Docker endpoint in Portainer.
  • Timeouts or network issues: Check connectivity between n8n, Portainer, and the Docker host.
  • Content-Type header: Must be set to application/x-tar for the build context; otherwise, the API may reject the request.

Common error messages:

  • "Unauthorized" or "Forbidden": API key issues.
  • "Cannot locate Dockerfile": Dockerfile missing in the build context.
  • "Build failed" with logs: Inspect logs for syntax or dependency errors in Dockerfile.

Links and References

Discussion