Docker icon

Docker

Interact with Docker

Actions15

Overview

This n8n node allows you to run a command inside a Docker container using a specified image. It is particularly useful for automating tasks that require isolated execution environments, such as running scripts, tools, or utilities without installing them on the host system. For example, you could use this node to execute a shell script in an Alpine Linux container, process files with a CLI tool, or test code in a clean environment.

Properties

Name Meaning
Image The name of the Docker image to use (e.g., alpine:latest, node:18).
Command A JSON array representing the command and its arguments to run inside the container.
Example:
["echo", "Hello World"]

Output

The output is a JSON object containing the results of the executed command:

{
  "stdout": "<string>", // Standard output from the command
  "stderr": "<string>"  // Standard error from the command
}
  • stdout: Captures everything written to standard output by the command.
  • stderr: Captures everything written to standard error by the command.

Dependencies

  • Docker Daemon: The node requires access to a Docker daemon (local or remote).
  • Credentials: You must configure Docker credentials in n8n (dockerCredentialsApi).
  • External Libraries: Uses the dockerode npm package for Docker API interaction.

Troubleshooting

  • No credentials got returned!
    This error occurs if Docker credentials are not configured or accessible. Ensure you have set up the required credentials in n8n.

  • Command must be an array!
    The "Command" property must be a valid JSON array. For example: ["ls", "-la"]. If you provide a string or invalid JSON, you'll see this error.

  • Image not found or pull failed
    If the specified Docker image does not exist or cannot be pulled, the node will fail. Double-check the image name and ensure your Docker daemon has internet access if pulling from Docker Hub.

Links and References

Discussion