Docker icon

Docker

Interact with Docker via Portainer API

Overview

This node allows you to restart a Docker container through the Portainer API. It is useful in scenarios where you need to programmatically manage container lifecycle, such as restarting a container after configuration changes, recovering from errors, or automating deployment workflows.

For example, you can use this node to:

  • Restart a specific container by its ID or name on a selected Docker endpoint.
  • Send a custom signal to the container during restart (e.g., SIGINT).
  • Specify a timeout period before forcibly killing the container if it does not stop gracefully.

Properties

Name Meaning
EndpointID Name or ID The Docker endpoint to access via Portainer API. Choose from a list of available endpoints or specify an ID using an expression.
Id The ID or name of the container to restart.
Additional Fields Optional parameters for the restart operation:
- Signal Signal to send to the container as an integer or string (e.g., SIGINT).
- T Number of seconds to wait before killing the container if it does not stop gracefully (timeout).

Output

The node outputs JSON data representing the response from the Portainer API after attempting to restart the container. This typically includes status information about the restart request. There is no binary output.

Dependencies

  • Requires a valid Portainer API endpoint URL and an API key credential configured in n8n.
  • The node uses the Portainer API to interact with Docker endpoints.
  • The user must have appropriate permissions on the Portainer instance to restart containers.

Troubleshooting

  • Common issues:

    • Invalid or missing endpoint ID: Ensure the selected endpoint exists and is accessible.
    • Incorrect container ID or name: Verify the container identifier is correct.
    • Insufficient permissions: The API key used must have rights to restart containers.
    • Network connectivity problems between n8n and the Portainer server.
  • Error messages:

    • Authentication errors: Check that the API key credential is valid and has not expired.
    • 404 Not Found: The specified container or endpoint does not exist.
    • Timeout errors: If the container takes too long to stop, consider increasing the timeout (t) value.

Links and References

Discussion