Automate Docker Container Management with n8n
detail.loadingPreview
Streamline your Docker operations by automating container management tasks. This n8n workflow allows you to trigger actions like starting, stopping, mounting, and unmounting disks via a secure webhook, ensuring efficient control over your containerized applications.
About This Workflow
This n8n workflow provides a robust solution for automating Docker container management. It leverages webhooks to receive commands and then dynamically executes the appropriate Docker operations. The workflow includes logic to validate server domains, set essential parameters like client and mount directories, and handle various container actions, from starting and stopping to disk mounting and unmounting. By defining specific commands within your API requests, you can gain precise control over your Docker environment, all orchestrated through the visual interface of n8n.
Key Features
- Webhook-driven Automation: Trigger Docker actions via a secure POST request to a dedicated webhook.
- Dynamic Command Execution: Supports starting, stopping, mounting, and unmounting Docker containers and disks.
- Server Domain Validation: Ensures commands are only processed for authorized server domains.
- Configurable Parameters: Easily set up client directories, mount points, and screen delimiters.
- Error Handling: Provides clear error responses for invalid requests or execution issues.
How To Use
- Configure the Webhook Node ('API'): Set the 'docker-n8n' path and choose 'POST' as the HTTP method. Configure Basic Authentication for security. The
webhookIdwill be provided upon saving. - Define Initial Parameters ('Parametrs'): Use a 'Set' node to define variables like
server_domain,clients_dir,mount_dir,screen_left, andscreen_right. - Implement Domain Validation ('If'): Connect the 'API' node to an 'If' node. Configure the 'If' node to check if the
server_domainfrom the incoming API request matches the one defined in the 'Parametrs' node. - Handle Invalid Domains: If the domain validation fails, connect the 'If' node to a 'Respond To Webhook' node ('422-Invalid server domain') to return an error response.
- Route Container Actions ('Container Actions'): If the domain is valid, connect the 'If' node to a 'Switch' node ('Container Actions'). Define rules for different
commandvalues received from the API (e.g.,container_start,container_stop,container_mount_disk,container_unmount_disk). - Execute Commands via SSH ('SSH'): For each action defined in the 'Switch' node, connect it to an 'SSH' node. Configure the
commandparameter in the 'SSH' node to execute the appropriate Docker command (e.g.,docker start {{ $json.container_name }}). Ensure you have SSH credentials set up. - Process Command Output ('Code1'): Connect the 'SSH' node to a 'Code' node ('Code1') to parse the output of the SSH command and format a success or error response.
- Respond to the Webhook: Connect the 'Code1' node to another 'Respond To Webhook' node (not explicitly shown but implied to complete the flow) to send the final status and any relevant data back to the caller.
Apps Used
Workflow JSON
{
"id": "b8b26e65-baa9-47a7-b891-56f39cf35e65",
"name": "Automate Docker Container Management with n8n",
"nodes": 22,
"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: b8b26e65-baa9...
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
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
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.
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.