Docker icon

Docker

Interact with Docker via Portainer API

Overview

This node allows users to delete Docker images via the Portainer API. It is useful for managing Docker environments by removing unused or unwanted images, helping to free up disk space and maintain a clean container environment. Typical scenarios include automated cleanup of old images in CI/CD pipelines or manual removal of specific images that are no longer needed.

For example, you can delete an image by specifying its name or ID on a particular Docker endpoint managed by Portainer. Additional options allow forcing deletion even if the image is in use by stopped containers or preventing the pruning of untagged parent images.

Properties

Name Meaning
EndpointID Name or ID The Docker endpoint (server) where the image resides. Choose from a list of available endpoints or specify an ID via expression.
Name The name or ID of the Docker image to delete.
Force (Optional) If true, forces removal of the image even if it is used by stopped containers or has other tags.
Noprune (Optional) If true, prevents deletion of untagged parent images during the removal process.

Output

The node outputs JSON data representing the response from the Portainer API after attempting to delete the specified Docker image. This typically includes status information about the deletion operation. The node does not output binary data.

Dependencies

  • Requires access to a Portainer instance with API enabled.
  • Requires an API key credential for authenticating requests to the Portainer API.
  • The node uses the Portainer API endpoint /api/endpoints/{endpointId}/docker to perform operations.
  • The user must configure the node with the URL of the Portainer server and valid credentials.

Troubleshooting

  • Common issues:

    • Invalid or missing endpointId: Ensure the selected endpoint exists and is accessible.
    • Incorrect image name or ID: Verify the image identifier is correct and exists on the target endpoint.
    • Insufficient permissions: The API key must have rights to delete images on the Portainer server.
    • Network connectivity problems between n8n and the Portainer server.
  • Error messages:

    • 404 Not Found: The specified image or endpoint does not exist.
    • 401 Unauthorized: Authentication failed; check API credentials.
    • 409 Conflict: Image is in use and force option was not set; try enabling Force to override.

Resolving these usually involves verifying credentials, endpoint selection, and image identifiers, as well as ensuring network access.

Links and References

Discussion