Docker icon

Docker

Interact with Docker via Portainer API

Overview

This node allows users to interact with Docker through the Portainer API, specifically focusing on managing Docker Swarm clusters. The "Swarm Leave" operation enables a Docker endpoint to leave a Swarm cluster. This is useful in scenarios where you want to remove a node from a Swarm, for example during maintenance, scaling down, or reconfiguring your container orchestration setup.

Practical examples include:

  • Removing a manager or worker node from a Docker Swarm cluster safely.
  • Forcing a node to leave the Swarm even if it might break the cluster (useful in emergency situations).
  • Automating cluster management workflows by integrating Swarm leave operations into CI/CD pipelines or infrastructure automation.

Properties

Name Meaning
EndpointID Name or ID The identifier of the Docker endpoint to access. You can select from a list of available endpoints or specify an ID using an expression.
Additional Fields Optional extra parameters for the operation:
  Force Boolean flag to force the node to leave the Swarm, even if it is the last manager or leaving would break the cluster.

Output

The node outputs JSON data representing the response from the Portainer API after attempting to leave the Swarm. This typically includes status information about the success or failure of the operation.

If the operation involves binary data (not indicated here), it would be summarized accordingly, but this node primarily deals with JSON responses.

Dependencies

  • Requires a valid connection to a Portainer API instance.
  • Needs an API key or token credential configured in n8n to authenticate requests to the Portainer API.
  • The node dynamically loads available Docker endpoints from the Portainer API to populate the "EndpointID" property.

Troubleshooting

  • Common issues:

    • Invalid or missing endpoint ID: Ensure the selected endpoint exists and is accessible.
    • Insufficient permissions: The API key used must have rights to manage Docker endpoints and Swarm clusters.
    • Forcing leave on the last manager may cause cluster instability; use the "Force" option cautiously.
  • Error messages:

    • Authentication errors: Check that the API credentials are correct and have not expired.
    • Endpoint not found: Verify the endpoint ID is correct and the Portainer instance is reachable.
    • Operation forbidden: Confirm the user has sufficient privileges to perform Swarm leave operations.

Links and References

Discussion