Actions15
Overview
This n8n node allows you to interact with Docker, specifically to run commands inside a container using a specified image. The "Network" resource with the "Run" operation is designed to pull a Docker image and execute a command within it, capturing both standard output and error streams. This is useful for automating tasks that require isolated execution environments, such as running scripts, testing code, or performing network operations in a controlled Docker context.
Practical examples:
- Running a network diagnostic tool (like
pingorcurl) inside a specific Docker image. - Executing custom scripts in a temporary container for data processing or transformation.
- Automating deployment or configuration steps that need to be run in a clean environment.
Properties
| Name | Meaning |
|---|---|
| Image | The name of the Docker image to use for running the command (e.g., alpine, ubuntu). |
| Command | The command to execute inside the container, provided as a JSON array (e.g., ["ls", "-la"]). |
Output
The node outputs a JSON object containing:
- stdout: The standard output produced by the executed command.
- stderr: The standard error output from the command.
Example output:
{
"stdout": "total 0\ndrwxr-xr-x 2 root root 6 Apr 14 12:00 .\ndrwxr-xr-x 1 root root 18 Apr 14 12:00 ..\n",
"stderr": ""
}
Dependencies
- Docker Daemon/API: Requires access to a Docker host where images can be pulled and containers can be run.
- Credentials: Needs valid Docker credentials configured in n8n (
dockerCredentialsApi).
Troubleshooting
No credentials got returned!
Cause: Docker credentials are not set up or selected in the node.
Solution: Ensure you have created and selected Docker credentials in the node's settings.Command must be an array!
Cause: The "Command" property is not a valid JSON array.
Solution: Enter the command as a JSON array, e.g.,["ls", "-la"].Image not found or cannot be pulled
Cause: The specified Docker image does not exist or there are network issues.
Solution: Verify the image name and ensure the Docker host has internet access or the image is available locally.