Portainer icon

Portainer

Trabalhe com dados da API do Portainer para gerenciar Docker

Overview

This node allows you to delete Docker images managed by Portainer through its API. It is useful in scenarios where you want to programmatically clean up unused or outdated Docker images from your environment to free up disk space or maintain a tidy image repository.

For example, after building and deploying new versions of your Docker images, you might want to remove old images that are no longer needed. This node can automate that deletion process by specifying the image ID and optionally forcing the deletion even if the image is currently in use.

Properties

Name Meaning
Environment ID The ID of the Portainer environment/endpoint where the Docker image resides.
Image ID The unique identifier of the Docker image to be deleted.
Force Delete Whether to force the deletion even if the image is currently in use (true or false).

Output

The node outputs the JSON response returned by the Portainer API after attempting to delete the specified image. This typically includes confirmation of deletion or error details if the operation failed.

No binary data output is produced by this operation.

Dependencies

  • Requires an active Portainer API endpoint with appropriate permissions to manage Docker images.
  • Requires an API key credential configured in n8n for authenticating requests to the Portainer API.
  • The node uses the Portainer API base URL and API key from the configured credentials.

Troubleshooting

  • Common Issues:

    • Attempting to delete an image that does not exist or has already been removed will result in an error.
    • Trying to delete an image that is currently used by running containers without setting "Force Delete" may fail.
    • Incorrect or missing environment ID or image ID parameters will cause the request to fail.
  • Error Messages:

    • 404 Not Found: The specified image ID does not exist in the given environment.
    • 409 Conflict: The image is in use by one or more containers; consider enabling "Force Delete".
    • 401 Unauthorized: Invalid or missing API key credential; verify your Portainer API authentication setup.

To resolve these errors, ensure the correct IDs are provided, enable force deletion if necessary, and confirm that your API credentials have sufficient permissions.

Links and References

Discussion