Docker icon

Docker

Interact with Docker via Portainer API

Actions107

Overview

This node allows you to interact with Docker containers through the Portainer API, specifically enabling you to rename an existing container. It is useful in scenarios where container names need to be updated for clarity, organization, or automation purposes without recreating the container.

For example, if you have a container running a service and want to update its name to reflect a new version or environment (e.g., from webapp-dev to webapp-prod), this node can perform that rename operation seamlessly.

Properties

Name Meaning
EndpointID Name or ID The identifier of the Portainer endpoint to access. You can select from a list of available endpoints or specify an ID using an expression.
Id The current ID or name of the Docker container you want to rename.
Name The new name to assign to the container. This value is sent as a query parameter named name in the rename request.

Output

The node outputs JSON data representing the response from the Portainer API after attempting to rename the container. This typically includes confirmation of the rename operation or error details if it failed.

No binary data output is involved in this operation.

Dependencies

  • Requires access to a Portainer instance with API enabled.
  • Needs an API key credential configured in n8n to authenticate requests to the Portainer API.
  • The node uses the Portainer API endpoint /api/endpoints/{endpointId}/docker/containers/{id}/rename with a query parameter name for the new container name.

Troubleshooting

  • Common issues:

    • Invalid or missing endpointId: Ensure the endpoint ID corresponds to a valid Portainer endpoint accessible by your credentials.
    • Incorrect container id: The container ID or name must exist on the specified endpoint.
    • Insufficient permissions: The API key used must have rights to rename containers.
    • Network or connectivity problems with the Portainer server.
  • Error messages:

    • 404 Not Found: Container with the specified ID does not exist.
    • 401 Unauthorized: Authentication failure due to invalid or missing API key.
    • 400 Bad Request: Possibly due to invalid new container name or malformed request.

To resolve these errors, verify the input parameters, ensure correct API credentials, and confirm network connectivity to the Portainer server.

Links and References

Discussion