Actions88
- Container Actions
- Container List
- Container Create
- Container Inspect
- Container Top
- Container Logs
- Container Changes
- Container Export
- Container Stats
- Container Resize
- Container Start
- Container Stop
- Container Restart
- Container Kill
- Container Update
- Container Rename
- Container Pause
- Container Unpause
- Container Attach
- Container Attach Websocket
- Container Wait
- Container Delete
- Container Archive Info
- Container Archive
- Put Container Archive
- Container Prune
- Image Actions
- Network Actions
- Volume Actions
- Swarm Actions
- Node Actions
- Secret Actions
- System Actions
- Exec Actions
- Service Actions
- Task Actions
Overview
This node enables interaction with Docker containers through the Portainer API, specifically allowing users to attach to a container's websocket stream. This operation is useful for real-time monitoring or interacting with a running container’s input/output streams such as logs, standard input, output, and error streams.
Common scenarios include:
- Streaming live logs from a container for debugging or monitoring.
- Attaching to a container’s stdin/stdout/stderr to interact with processes inside the container.
- Capturing container output streams for further processing in an automation workflow.
For example, you might use this node to attach to a web server container to monitor its logs in real time or send commands directly to a containerized application via stdin.
Properties
| Name | Meaning |
|---|---|
| EndpointID Name or ID | The identifier of the Portainer endpoint where the Docker container resides. You can select from a list of available endpoints or specify one using an expression. |
| Id | The ID or name of the Docker container to which you want to attach the websocket. |
| Additional Fields | Optional parameters to customize the websocket attachment: |
| - Detach Keys | Override the key sequence used to detach from the container session. Accepts a single character [a-z] or ctrl-<value> where <value> can be letters or special characters like @, ^, [, ,, or _. |
| - Logs | Boolean flag to indicate whether to return the container logs. |
| - Stream | Boolean flag to indicate whether to stream the output continuously. |
| - Stdin | Boolean flag to attach to the container’s standard input stream. |
| - Stdout | Boolean flag to attach to the container’s standard output stream. |
| - Stderr | Boolean flag to attach to the container’s standard error stream. |
Output
The node outputs JSON data representing the response from the Portainer API when attaching to the container websocket. This typically includes streamed data from the container’s logs or input/output streams depending on the options selected.
If streaming is enabled, the output will contain continuous data chunks from the container’s stdout, stderr, or logs.
Binary data is not explicitly handled by this node; all output is expected to be JSON-formatted text data representing the container streams.
Dependencies
- Requires access to a Portainer instance with the Docker environment managed.
- Needs an API key credential configured in n8n to authenticate requests against the Portainer API.
- The node uses the Portainer API endpoint
/api/endpoints/{endpointId}/docker/containers/{id}/attach/ws(implied by the operation) to establish the websocket connection.
Troubleshooting
- Invalid Endpoint or Container ID: If the specified endpoint or container ID does not exist or is incorrect, the node will fail to connect. Verify that the endpoint and container IDs are correct and accessible.
- Authentication Errors: Ensure the API key credential is valid and has sufficient permissions to access the Portainer API and the target endpoint.
- Websocket Connection Issues: Network issues or firewall restrictions may block websocket connections. Confirm network connectivity and that websockets are allowed.
- Incorrect Detach Keys: Using invalid detach key sequences may prevent proper detachment from the container session. Use only supported characters as described.
- No Output When Flags Are False: If none of the
logs,stream,stdin,stdout, orstderrflags are set to true, the node may not receive any data. Make sure to enable at least one stream option.