n8n

How to Automate Docker SSH Service Management?

Run container lifecycle tasks from a simple API. Teams can deploy, start, stop, suspend, unsuspend, and remove Docker based apps on a remote server without logging in to the box every time. This is ideal for IT or hosting teams that need safe and repeatable server operations.

Incoming API calls are secured with basic auth and validated against an allowed server domain. Requests are routed by action using two switch blocks, one for service tasks and one for container tasks. Each action builds a ready to run shell script, which is sent over SSH to the Docker host. Output is parsed into clean JSON so your portal gets a clear status and message. Extra checks cover logs, stats, user actions, version info, web server setup, network, and ACL.

Setup is simple. Create SSH access to a Docker host and add basic auth for the API. Set the server domain and local paths in the parameters block. Point your portal to the production webhook URL and send JSON with action and domain. Expect faster turnarounds, fewer mistakes, and easier scale. Great for managed service providers and internal ops that need consistent container control.

What are the key features?

  • Secure API webhook with basic auth and domain check that returns a clear 422 error when the domain does not match.
  • Action routing with two switch blocks that separate service actions from container actions for clean control.
  • Templated bash scripts for deploy, start, stop, suspend, unsuspend, terminate, mount disk, unmount disk, logs, change password, change package, and more.
  • Remote command execution over SSH using the script built for each request.
  • Response normalization by parsing stdout into consistent JSON for your portal.
  • Health and visibility with inspect, stats, container stat, and dependent container checks.
  • Web server and compose setup support through dedicated configuration steps.
  • Network and access control helpers with ACL and network info actions.

What are the benefits?

  • Reduce manual server work from 30 minutes to 2 minutes per request
  • Automate up to 90% of routine container tasks
  • Cut command errors by up to 80% with scripted actions
  • Handle 10 times more requests with the same team size
  • Connect your portal API to the server seamlessly over SSH

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. In the n8n credentials manager, create an HTTP Basic Auth credential for the API node. Use a strong username and password and save it.
  3. In the n8n credentials manager, create an SSH credential for your Docker host. Enter host, port, username, and either password or private key. Make sure the user can run Docker commands.
  4. Open the Parameters set node and update server_domain, clients_dir, and mount_dir. Keep the technical screen parameters as they are.
  5. Open the API webhook node and copy the Production URL. This is the endpoint your portal or system will call.
  6. Send a test request with basic auth and JSON like { "action": "test_connection", "domain": "your-domain" }. You should receive a 200 response if the server domain matches.
  7. If you get a 422 response, check the server_domain value in the Parameters node and correct the domain you send in the request body.
  8. Run a deploy test by sending { "action": "deploy", "domain": "your-domain" } and confirm that the server creates the compose directory and starts the containers.
  9. Use start and stop actions to confirm lifecycle control. Then call stat, inspect, or logs actions to verify status and visibility.
  10. If SSH commands fail, verify network access to the server, user permissions for Docker, and that Docker is installed and running.
  11. Review the Code node output to confirm the response JSON is parsed correctly. Ensure your scripts echo JSON or a success message.
  12. Lock access by using strong basic auth and, if possible, allow only trusted IPs to reach the webhook URL.

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.

Credits:
PUQcloud

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.