Docker icon

Docker

Interact with Docker via Portainer API

Actions107

Overview

This node allows you to stop a Docker container by interacting with the Portainer API. It is useful in automation workflows where you need to programmatically control container lifecycle, such as stopping containers during deployment pipelines, maintenance windows, or scaling down services.

For example, you can use this node to:

  • Stop a specific container by its ID or name on a selected Docker endpoint.
  • Gracefully stop containers by sending specific signals (e.g., SIGINT).
  • Define a timeout period before forcibly killing the container if it does not stop within the given time.

Properties

Name Meaning
EndpointID Name or ID Select the Docker endpoint to access. You can choose from a list of available endpoints or specify an ID using an expression.
Id The ID or name of the container you want to stop.
Additional Fields Optional parameters:
- Signal Signal to send to the container to stop it, e.g., SIGINT.
- T Number of seconds to wait before forcibly killing the container if it does not stop gracefully.

Output

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

Dependencies

  • Requires a valid Portainer API endpoint URL and an API key credential configured in n8n to authenticate requests.
  • The node uses the Portainer API to manage Docker containers remotely.
  • The "EndpointID" property must correspond to a valid Docker endpoint managed by Portainer.

Troubleshooting

  • Invalid EndpointID: If the specified endpoint ID is incorrect or inaccessible, the node will fail to connect. Verify the endpoint exists and your credentials have access.
  • Container Not Found: If the container ID or name does not exist on the selected endpoint, the API will return an error. Double-check the container identifier.
  • Insufficient Permissions: Ensure the API key used has permissions to stop containers on the target endpoint.
  • Timeout Issues: If the container does not stop within the specified timeout (t), it may be forcibly killed. Adjust the timeout value as needed.
  • Signal Format: The signal must be a valid string or integer recognized by Docker; invalid signals will cause errors.

Links and References

Discussion