{"updatedAt":"2025-11-29T20:49:05.134Z","createdAt":"2025-11-29T20:48:09.567Z","id":"UCNbmE7E4cwkqPUz","name":"docker manage","active":false,"isArchived":false,"nodes":[{"parameters":{"httpMethod":"POST","path":"c851e840-457c-4050-8803-4e6d258580e1","options":{}},"id":"a9418004-77a7-4fc3-a6da-e64f0c85e4de","name":"Webhook","type":"n8n-nodes-base.webhook","position":[64,160],"typeVersion":2.1,"webhookId":"77095d61-8836-4ad8-995d-f66746369cbf"},{"parameters":{"modelId":{"__rl":true,"mode":"list","value":"gpt-4.1-mini","cachedResultName":"GPT-4.1-MINI"},"responses":{"values":[{"role":"system","content":"You are a senior IT specialist experienced in debugging distributed systems, containers, Linux services, and application logs. When the user provides log output or an error message, you must:\n\nAnalyze the logs carefully and respond in a structured format:\n\nSummary\nShort, concise explanation of what's happening.\n\nMost Likely Root Cause\nOne clear sentence. If unknown, say so and state what’s missing.\n\nImpact\nExplain if functionality is broken, partially limited, or unaffected.\n\nKey Evidence From Logs\nList only the relevant log lines and briefly explain each.\n\nSeverity Level\nRate 1–5 (1 negligible, 5 critical). Include a one-line justification.\n\nRecommended Next Steps\nBullet actionable steps. Include different paths if needed (example: “If you use USB devices…”).\n\nFollow-up / What to Monitor\nOne or two items the user should watch for or collect next.\n\nGuidelines:\n\nBe concise and structured. No long essays.\n\nNever just quote logs back. Interpret them.\n\nIf assumptions are required, state them explicitly.\n\nIf the logs do not contain enough info, say so and request specifics.\n\nTone should be calm, confident, and clear like a senior engineer helping a teammate.\n\nAvoid unnecessary technical jargon unless required.\n\nFocus on actionable clarity."},{"content":"={{ $('get logs').item.json.stdout }}"}]},"builtInTools":{},"options":{}},"id":"805eb9a4-abc4-4c68-b525-28847c91094a","name":"Message a model","type":"@n8n/n8n-nodes-langchain.openAi","position":[1712,640],"typeVersion":2,"credentials":{"openAiApi":{"id":"PvUURuR361IXH0ve","name":"OpenAi account"}}},{"parameters":{"updates":["message"],"additionalFields":{}},"id":"24fb74b7-9c06-4f37-9c25-a9befebb1ed1","name":"Telegram Trigger","type":"n8n-nodes-base.telegramTrigger","position":[96,672],"typeVersion":1.2,"webhookId":"06e6be4d-8b16-4c5f-9a9b-967e74cc66ff","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"a4f85833-5791-4513-bef5-f31c582bf26a","operator":{"type":"string","operation":"contains"},"leftValue":"={{ $json.message.text.toLowerCase() }}","rightValue":"logs"}]}},{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"52a99c27-c2bb-49b5-9ca9-27c3de1aa9ac","operator":{"type":"string","operation":"contains"},"leftValue":"={{ $json.message.text.toLowerCase() }}","rightValue":"restart"}]}},{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"f12f78c4-e959-4e50-9b1d-2a605169387d","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.message.text.toLowerCase() }}","rightValue":"status"}]}},{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"3e13d044-3bfe-4669-a107-ace1b573240e","operator":{"name":"filter.operator.equals","type":"string","operation":"equals"},"leftValue":"={{ $json.message.text.toLowerCase() }}","rightValue":"update"}]}}]},"options":{}},"id":"197134d7-14db-46e8-976b-fd3ea6e6ee5e","name":"Switch","type":"n8n-nodes-base.switch","position":[416,1088],"typeVersion":3.3},{"parameters":{"mode":"combine","combineBy":"combineByPosition","options":{}},"id":"b8cd9d32-f9fe-42e8-b845-37f1f658f9ad","name":"Merge","type":"n8n-nodes-base.merge","position":[1040,640],"typeVersion":3.2},{"parameters":{"mode":"combine","combineBy":"combineByPosition","options":{}},"id":"acba80b9-bf47-4228-a91c-cd0a2783f297","name":"Merge1","type":"n8n-nodes-base.merge","position":[1040,1008],"typeVersion":3.2},{"parameters":{"rules":{"values":[{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"5f956f73-4789-4fae-bedc-7c1f0edfc2d2","operator":{"type":"string","operation":"equals"},"leftValue":"={{ $json.body.heartbeat.msg }}","rightValue":"running"}]}},{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"d1ec668d-53e8-44b2-9cb6-6a4de3bcec07","operator":{"type":"string","operation":"notEquals"},"leftValue":"={{ $json.body.heartbeat.msg }}","rightValue":"running"}]}}]},"options":{}},"id":"6d28964d-53a2-4760-95d8-9b32311e8b5c","name":"Switch1","type":"n8n-nodes-base.switch","position":[288,160],"typeVersion":3.3},{"parameters":{"conditions":{"options":{"version":2,"leftValue":"","caseSensitive":true,"typeValidation":"strict"},"combinator":"and","conditions":[{"id":"30a53424-65b9-4a9b-a4cd-e78933c8441b","operator":{"type":"string","operation":"empty","singleValue":true},"leftValue":"={{ $json.stderr }}","rightValue":""}]},"options":{}},"id":"e66c9386-c788-4b53-a0ac-1dbd186d8f90","name":"If","type":"n8n-nodes-base.if","position":[1776,1008],"typeVersion":2.2},{"parameters":{"chatId":"8209283663","text":"={{ $json.body.msg }}","replyMarkup":"replyKeyboard","replyKeyboardOptions":{},"additionalFields":{"appendAttribution":false,"reply_to_message_id":0}},"id":"e2773fd4-c08e-43c8-b737-4b37840ebed8","name":"OK Message","type":"n8n-nodes-base.telegram","position":[512,64],"typeVersion":1.2,"webhookId":"77af8e80-627d-4140-8d4a-217ff22ed31b","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"={{ $json.body.monitor.docker_container }} reported an issue : {{ $json.body.heartbeat.msg }} at {{ $json.body.heartbeat.time }}","replyMarkup":"replyKeyboard","replyKeyboard":{"rows":[{"row":{"buttons":[{"text":"={{ $json.body.monitor.docker_container }} Logs","additionalFields":{}},{"text":"={{ $json.body.monitor.docker_container }} Restart","additionalFields":{}}]}}]},"replyKeyboardOptions":{},"additionalFields":{"appendAttribution":false,"reply_to_message_id":0}},"id":"b3be1e4e-2891-44f5-86e0-13d45e5aaf88","name":"ERROR Message","type":"n8n-nodes-base.telegram","position":[512,256],"typeVersion":1.2,"webhookId":"5ab67fa8-6936-4cf4-93c1-a249f0a6a0ff","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"=Analyzing Log File...","additionalFields":{"appendAttribution":false}},"id":"30b13373-c151-430c-a95a-6eb8fa3f14b0","name":"Status Update","type":"n8n-nodes-base.telegram","position":[1488,640],"typeVersion":1.2,"webhookId":"74fe0f97-3e35-48cd-96b2-8b222505b847","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"={{ $json.output[0].content[0].text }}","additionalFields":{"appendAttribution":false}},"id":"24e0c35a-5de5-40f6-be7c-515bf84b04c0","name":"Log Analysis","type":"n8n-nodes-base.telegram","position":[2064,640],"typeVersion":1.2,"webhookId":"fe8bb2b6-097d-40ee-8108-5d5652d35ce7","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"=Attempting to restart...","additionalFields":{"appendAttribution":false}},"id":"716ff4d7-42f6-4fa6-8bcb-bbee571fc9b1","name":"Restart Message","type":"n8n-nodes-base.telegram","position":[1264,1008],"typeVersion":1.2,"webhookId":"a01b2aeb-bf4c-4184-b0d4-255cf9cb8768","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"=Successfull restarting {{ $json.stdout }}","additionalFields":{"appendAttribution":false}},"id":"fe73b4da-24b7-442a-bbb2-44b12505880e","name":"Success restart","type":"n8n-nodes-base.telegram","position":[2064,912],"typeVersion":1.2,"webhookId":"4a8ee06c-15cb-4da3-aeb6-101869cf3b88","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"=Restart failed\n{{ $('restart container').item.json.stderr }}","additionalFields":{"appendAttribution":false}},"id":"10144c60-1c3f-408d-a9b2-39a384907971","name":"Restart Failed","type":"n8n-nodes-base.telegram","position":[2064,1104],"typeVersion":1.2,"webhookId":"3821d08a-ddd7-4f66-b302-57518808eff7","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"={{ $json.stdout }}","additionalFields":{"appendAttribution":false,"parse_mode":"HTML"}},"id":"5a10f813-651f-425b-a660-756e1f108bae","name":"Docker Status","type":"n8n-nodes-base.telegram","position":[1072,1456],"typeVersion":1.2,"webhookId":"8e2f52ba-ec85-46f3-b42f-d80730cc4283","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"command":"=docker logs --tail 100 {{ $json.service_name }}","cwd":"/root/"},"id":"e83dbb5a-0b89-4455-ac4b-4d13dee186c5","name":"get logs","type":"n8n-nodes-base.ssh","position":[1264,640],"typeVersion":1,"credentials":{"sshPassword":{"id":"9jCP71iIVSvJoPxR","name":"SSH Password account"}}},{"parameters":{"command":"=docker restart {{ $('Merge1').item.json.service_name }}","cwd":"/root/"},"id":"7d621bb8-59bf-43a7-adea-c6930356a398","name":"restart container","type":"n8n-nodes-base.ssh","position":[1488,1008],"typeVersion":1,"credentials":{"sshPassword":{"id":"9jCP71iIVSvJoPxR","name":"SSH Password account"}}},{"parameters":{"command":"docker ps --format \"{{.Names}}\\t{{.Status}}\"","cwd":"/root/"},"id":"3813d41d-00fe-47dc-9590-40d76e847aa0","name":"docker ps","type":"n8n-nodes-base.ssh","position":[848,1456],"typeVersion":1,"credentials":{"sshPassword":{"id":"9jCP71iIVSvJoPxR","name":"SSH Password account"}}},{"parameters":{"language":"python","pythonCode":"import re\nimport json\n\ndef extract_update_summary(stdout):\n match = re.search(r'Update Summary:\\n({.*?\\})', stdout, re.DOTALL)\n if not match:\n return {}\n update_json = match.group(1)\n update_json_clean = re.sub(r',\\s*([\\]\\}])', r'\\1', update_json)\n return json.loads(update_json_clean)\n\ndef format_update_message(update_summary):\n status_parts = []\n for compose_file, updates in update_summary.items():\n service = compose_file.replace('-compose.yaml', '')\n if updates == [\"none\"]:\n status_parts.append(f\"{service}: No updates\")\n else:\n status_parts.append(f\"{service}: Updated ({', '.join(updates)})\")\n return \"; \".join(status_parts)\n\n# n8n passes items as a list of dicts; get the \"stdout\" field from the input\nstdout = _input.first().json.stdout\nupdate_summary = extract_update_summary(stdout)\nmessage = format_update_message(update_summary)\nreturn [{\"message\": message}]\n"},"id":"308111a8-7470-476e-8b1b-b10524d52ec2","name":"Code in Python (Beta)","type":"n8n-nodes-base.code","position":[1248,1856],"typeVersion":2},{"parameters":{"command":"./update-all-docker-compose.sh","cwd":"/root/"},"id":"68c5641e-bb14-41c9-aa82-67e6f24276ef","name":"Update Docker","type":"n8n-nodes-base.ssh","position":[1024,1856],"notesInFlow":true,"typeVersion":1,"alwaysOutputData":true,"credentials":{"sshPassword":{"id":"9jCP71iIVSvJoPxR","name":"SSH Password account"}}},{"parameters":{"chatId":"8209283663","text":"=Running Update...","additionalFields":{"appendAttribution":false,"parse_mode":"HTML"}},"id":"fc1658de-3fc2-4481-86cb-612ea51bbb92","name":"Update Msg","type":"n8n-nodes-base.telegram","position":[800,1856],"typeVersion":1.2,"webhookId":"43e19fea-7577-4dd3-a659-e695c15eeb97","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"chatId":"8209283663","text":"={{ $json.message }}","additionalFields":{"appendAttribution":false,"parse_mode":"HTML"}},"id":"38c58f7a-8afc-44e6-9869-fa1179eb7392","name":"Update Msg1","type":"n8n-nodes-base.telegram","position":[1536,1856],"typeVersion":1.2,"webhookId":"09bc92cc-40a8-4b28-af58-060970ec69ca","credentials":{"telegramApi":{"id":"L9KHcMiteyKROF5r","name":"Telegram account"}}},{"parameters":{"content":"## Incoming Webhook\n\nuse a webhook from tools like Uptime Kuma","height":384},"id":"61ae9bd8-68c8-44e6-aa8e-594355423960","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[0,0],"typeVersion":1},{"parameters":{"content":"## User Interaction\n\nAllow users to triggers events directly from Telegram","height":304,"width":352},"id":"1b880d57-d4ad-4a5c-a2a4-40634190fd2c","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[0,560],"typeVersion":1},{"parameters":{"language":"python","pythonCode":"def extract_service_name(message):\n # Split by spaces\n parts = message.split()\n # Take the first part (service name)\n if parts:\n return parts[0]\n else:\n return ''\n\n# Example usage:\nincoming_message = _input.first().json.message.text\nservice_name = extract_service_name(incoming_message)\nreturn {\n \"service_name\": service_name\n}"},"id":"f37914c6-5e0a-42ae-9c57-d2024b464128","name":"Extract the Service Name","type":"n8n-nodes-base.code","position":[800,640],"typeVersion":2},{"parameters":{"content":"## Issue Analyzer\nAutomatically analyse the log file for a docker container and provide feedback to the user","height":320,"width":1488},"id":"68ad89f8-defe-47a9-b2a3-232062c89f85","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[784,512],"typeVersion":1},{"parameters":{"content":"## Docker Restart Service\nAutomatically restart a given docker container","height":352,"width":1488},"id":"2a080819-9c59-4c9a-9d29-430ff2cd5435","name":"Sticky Note3","type":"n8n-nodes-base.stickyNote","position":[768,896],"typeVersion":1},{"parameters":{"content":"## Allow the user to get all current deployed docker container\n","height":352,"width":752},"id":"320eb71d-4a54-435e-b703-09ce97416bfb","name":"Sticky Note4","type":"n8n-nodes-base.stickyNote","position":[768,1328],"typeVersion":1},{"parameters":{"content":"## Automatically update all docker images on the server","height":352,"width":1232},"id":"be540fdf-4ed1-4457-9a6f-2ee0987ee384","name":"Sticky Note5","type":"n8n-nodes-base.stickyNote","position":[768,1728],"typeVersion":1},{"parameters":{"content":"## Custom Script for your Docker server\n\n''bash\nProcessing hompage-compose.yaml\n GNU nano 7.2 update-all-docker-compose.sh\n#!/bin/bash\ndeclare -A UPDATED_CONTAINERS\nN8N_FILE=\"n8n-compose.yaml\" # Adjust to your n8n compose filename\n\nfor file in *-compose.yaml; do\n if [[ \"$file\" == \"$N8N_FILE\" ]]; then\n echo \"Skipping $file (n8n instance)\"\n continue\n fi\n\n echo \"Processing $file\"\n UPDATED_IMAGES=()\n\n OUTPUT=$(docker compose -f \"$file\" pull 2>&1)\n echo \"$OUTPUT\"\n\n while IFS= read -r line; do\n if [[ $line =~ \"Downloaded newer image\" ]]; then\n IMAGE=$(echo \"$line\" | awk '{print $2}')\n UPDATED_IMAGES+=(\"$IMAGE: updated\")\n elif [[ $line =~ \"Image is up to date\" ]]; then\n IMAGE=$(echo \"$line\" | awk '{print $2}')\n UPDATED_IMAGES+=(\"$IMAGE: already up-to-date\")\n fi\n done <<< \"$OUTPUT\"\n\n docker compose -f \"$file\" up -d\n\n UPDATED_CONTAINERS[\"$file\"]=${UPDATED_IMAGES[@]:-none}\ndone\n\necho \"Update Summary:\"\necho \"{\"\nfor file in \"${!UPDATED_CONTAINERS[@]}\"; do\n echo \" \\\"$file\\\": [\"\n for status in ${UPDATED_CONTAINERS[$file]}; do\n echo \" \\\"$status\\\",\"\n done\n echo \" ],\"\ndone\necho \"}\"\n''","height":944,"width":464},"id":"77380b75-b58f-4d30-8859-8700df1a686f","name":"Sticky Note6","type":"n8n-nodes-base.stickyNote","position":[768,2112],"typeVersion":1}],"connections":{"If":{"main":[[{"node":"Success restart","type":"main","index":0}],[{"node":"Restart Failed","type":"main","index":0}]]},"Merge":{"main":[[{"node":"get logs","type":"main","index":0}]]},"Merge1":{"main":[[{"node":"Restart Message","type":"main","index":0}]]},"Switch":{"main":[[{"node":"Merge","type":"main","index":0}],[{"node":"Merge1","type":"main","index":0}],[{"node":"docker ps","type":"main","index":0}],[{"node":"Update Msg","type":"main","index":0}]]},"Switch1":{"main":[[{"node":"OK Message","type":"main","index":0}],[{"node":"ERROR Message","type":"main","index":0}]]},"Webhook":{"main":[[{"node":"Switch1","type":"main","index":0}]]},"get logs":{"main":[[{"node":"Status Update","type":"main","index":0}]]},"docker ps":{"main":[[{"node":"Docker Status","type":"main","index":0}]]},"Update Msg":{"main":[[{"node":"Update Docker","type":"main","index":0}]]},"Status Update":{"main":[[{"node":"Message a model","type":"main","index":0}]]},"Update Docker":{"main":[[{"node":"Code in Python (Beta)","type":"main","index":0}]]},"Message a model":{"main":[[{"node":"Log Analysis","type":"main","index":0}]]},"Restart Message":{"main":[[{"node":"restart container","type":"main","index":0}]]},"Telegram Trigger":{"main":[[{"node":"Switch","type":"main","index":0},{"node":"Extract the Service Name","type":"main","index":0}]]},"restart container":{"main":[[{"node":"If","type":"main","index":0}]]},"Code in Python (Beta)":{"main":[[{"node":"Update Msg1","type":"main","index":0}]]},"Extract the Service Name":{"main":[[{"node":"Merge","type":"main","index":1},{"node":"Merge1","type":"main","index":1}]]}},"settings":{"executionOrder":"v1"},"staticData":null,"meta":{"templateCredsSetupCompleted":true},"pinData":{},"versionId":"0bf0ffe4-c9bb-492d-9110-4584b7c054dd","activeVersionId":null,"triggerCount":0,"shared":[{"updatedAt":"2025-11-29T20:48:09.567Z","createdAt":"2025-11-29T20:48:09.567Z","role":"workflow:owner","workflowId":"UCNbmE7E4cwkqPUz","projectId":"sYuiFAb87pAir6jV"}],"activeVersion":null,"tags":[]}