API-Driven Docker Container & Server Management
detail.loadingPreview
This n8n workflow provides a robust, API-driven solution for remotely managing Docker containers and performing server operations via SSH. It automates common DevOps tasks, ensuring secure execution and standardized responses for seamless integration with other systems.
About This Workflow
Streamline your infrastructure management with this powerful n8n workflow, designed to bring API control to your Docker environments. This solution acts as a secure gateway, allowing external systems or internal tools to trigger specific container actions and server commands via a simple webhook. It incorporates vital features like server domain validation to prevent unauthorized operations, and securely executes dynamic shell commands on remote servers via SSH. By centralizing common DevOps tasks and providing a unified JSON response structure, this workflow drastically reduces manual intervention and boosts operational efficiency.
Key Features
- API-Driven Control: Trigger container start/stop, disk mounts/unmounts, and other custom commands via a simple
POSTrequest to a secure webhook endpoint. - Secure Remote Execution: Leverages SSH with password authentication to execute shell commands securely on your remote servers.
- Server Domain Validation: Ensures commands are only executed on approved server domains, enhancing security and preventing misconfigurations.
- Standardized JSON Responses: All command outputs are processed and returned in a consistent JSON format, making integration with other systems straightforward.
- Extensible Command Switching: Easily add new container actions or server commands by extending the
Switchnode, tailoring the workflow to your specific operational needs.
How To Use
- Configure API Webhook:
- Open the "API" node.
- Note the
webhookIdandpath(e.g.,/docker-n8n). This will form your webhook URL (e.g.,YOUR_N8N_URL/webhook/YOUR_WEBHOOK_ID/docker-n8n). - Set up the
httpBasicAuthcredentials for secure access.
- Define Server Parameters:
- Edit the "Parametrs" (Set) node.
- Update the
server_domainvalue to your target server's domain (e.g.,d01-test.uuq.pl). This domain will be used for validation. - Adjust
clients_dir,mount_dir, and other variables as needed for your server environment; these can be used to construct dynamic SSH commands.
- Set up SSH Credentials:
- Open the "SSH" node.
- Configure the SSH password credentials to allow n8n to connect to your remote server. Ensure the user has the necessary permissions to execute Docker and system commands.
- Extend Container Actions (Optional):
- The "Container Actions" (Switch) node handles different commands received via the API. To add new commands (e.g.,
container_exec,container_logs), create new branches in the switch and configure the subsequent nodes to generate the appropriateshcommand for the "SSH" node.
- The "Container Actions" (Switch) node handles different commands received via the API. To add new commands (e.g.,
- Test the Workflow:
- Send a
POSTrequest to your webhook URL with basic authentication. - The request body should include
server_domain(for validation) andcommand(e.g.,{"server_domain": "d01-test.uuq.pl", "command": "container_start", "container_name": "my-app"}). - Monitor the execution in n8n and observe the structured JSON response.
- Send a
Apps Used
Workflow JSON
{
"id": "ede6d7c3-e4a1-45e0-a435-b0558eb55930",
"name": "API-Driven Docker Container & Server Management",
"nodes": 21,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: ede6d7c3-e4a1...
About the Author
AI_Workflow_Bot
LLM Specialist
Building complex chains with OpenAI, Claude, and LangChain.
Statistics
Related Workflows
Discover more workflows you might like
Effortless Bug Reporting: Slack Slash Command to Linear Issue
Streamline your bug reporting process by instantly creating Linear issues directly from Slack using a simple slash command. This workflow enhances team collaboration by providing immediate feedback and a structured approach to logging defects, saving valuable time for development and QA teams.
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.