n8n

How to Automate Docker Provisioning and Control?

Run container services from a single API that talks to your Docker host over secure SSH. This setup fits hosting teams and IT groups that need to deploy, start, stop, or pause customer containers at scale with clear results. It reduces manual server work and keeps actions consistent.

An authenticated webhook receives POST requests. It checks the server domain, then routes each request to the right action using Switch nodes. Set nodes build shell commands for tasks like deploy, start, stop, inspect, disk mount, users, and network checks. The SSH node runs the command on the server. A Code node reads the server output and returns clean JSON. You get a 200 success response or a 422 error when the domain is wrong.

Prepare SSH access to a Docker host and set your server domain and folders. Expect faster service delivery, fewer mistakes, and less hands-on time per request. Use it to auto provision from billing apps, pause unpaid services, adjust packages, or manage disks for customer containers.

What are the key features?

  • Secure webhook with Basic Auth to receive POST requests for container actions.
  • Domain validation using If and Respond nodes that returns a 422 error on mismatch.
  • Action routing with Switch nodes that split requests into container, service, and stats paths.
  • Shell script generation with Set nodes for deploy, start, stop, suspend, unsuspend, and disk mount tasks.
  • Remote command execution over SSH on the Docker host using the SSH node.
  • Structured JSON responses built by a Code node that parses server output safely.
  • Support for compose deployment, nginx setup, users and password updates, and ACL or network checks.
  • Unified API response back to the caller with Respond to Webhook for easy system integration.

What are the benefits?

  • Reduce manual server work from 60 minutes to 5 minutes per request by using a single API call
  • Streamline container lifecycle tasks by 80 percent with routed actions and ready scripts
  • Cut configuration errors by 70 percent through domain checks and standardized commands
  • Handle 5 times more service requests with the same team by removing repetitive SSH steps
  • Connect API calls to Docker hosts securely, keeping a clear audit in execution logs

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. Open the Webhook node and create a Basic Auth credential. Set a username and a strong password. Save the credential and confirm the node shows it as connected.
  3. Create an SSH credential for your Docker host. In the SSH node, choose Create new credential, then enter host, port, username, and either a password or a private key. Test the connection if available.
  4. In the Parameters Set node, update server_domain, clients_dir, and mount_dir to match your environment. Do not change the screen values.
  5. Copy the production webhook URL from the Webhook node. Make sure it is reachable over HTTPS from your calling system.
  6. On the Docker host, ensure Docker and Docker Compose or compose plugin are installed, and the SSH user has permission to run Docker. Create the clients directory path if it does not exist.
  7. Send a POST request to the webhook with a test action like test_connection and your domain. Expect a JSON 200 response when the domain matches. If the domain is wrong, you will get a 422 Invalid server domain.
  8. Trigger a deploy action with a sample domain and required fields. Check that compose files and services are created on the host and containers start correctly.
  9. Test lifecycle actions start, stop, suspend, unsuspend, and terminated. Confirm each returns a clear JSON message and that the container state changes on the server.
  10. Check stats and inspect actions. Review the returned JSON to confirm container details, logs, and status are accurate.
  11. Monitor n8n execution logs for SSH stdout and stderr. If you see permission errors, add the SSH user to the docker group and re-login. If folders are missing, create the clients_dir path.
  12. If responses fail to parse, make sure the server scripts print valid JSON. Update environment variables and paths in the Set nodes if your directories differ.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.