{"id":21088050,"url":"https://github.com/petervinter/docker-graceful-shutdown-for-windows","last_synced_at":"2026-04-11T17:01:57.511Z","repository":{"id":263329423,"uuid":"890039313","full_name":"PeterVinter/docker-graceful-shutdown-for-windows","owner":"PeterVinter","description":"Scripts for gracefully shutting down Docker containers on Windows systems","archived":false,"fork":false,"pushed_at":"2024-11-18T00:34:35.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T05:41:48.475Z","etag":null,"topics":["container-management","container-orchestration","devops","docker","docker-compose","docker-windows","powershell","windows","windows-terminal"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterVinter.png","metadata":{"files":{"readme":"Readme.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-17T21:17:46.000Z","updated_at":"2024-11-18T00:34:38.000Z","dependencies_parsed_at":"2024-11-17T22:25:41.457Z","dependency_job_id":"b2729caf-d06e-410d-a82a-b33d94dc26f6","html_url":"https://github.com/PeterVinter/docker-graceful-shutdown-for-windows","commit_stats":null,"previous_names":["petervinter/docker-graceful-shutdown-for-windows"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterVinter%2Fdocker-graceful-shutdown-for-windows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterVinter%2Fdocker-graceful-shutdown-for-windows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterVinter%2Fdocker-graceful-shutdown-for-windows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterVinter%2Fdocker-graceful-shutdown-for-windows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterVinter","download_url":"https://codeload.github.com/PeterVinter/docker-graceful-shutdown-for-windows/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532531,"owners_count":20306152,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["container-management","container-orchestration","devops","docker","docker-compose","docker-windows","powershell","windows","windows-terminal"],"created_at":"2024-11-19T21:14:03.483Z","updated_at":"2025-12-28T17:36:58.311Z","avatar_url":"https://github.com/PeterVinter.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Docker Graceful Shutdown Utility\n\n![License](https://img.shields.io/github/license/PeterVinter/docker-graceful-shutdown-for-windows)\n![Last Commit](https://img.shields.io/github/last-commit/PeterVinter/docker-graceful-shutdown-for-windows)\n![Stars](https://img.shields.io/github/stars/PeterVinter/docker-graceful-shutdown-for-windows)\n![Issues](https://img.shields.io/github/issues/PeterVinter/docker-graceful-shutdown-for-windows)\n![PowerShell](https://img.shields.io/badge/PowerShell-%235391FE.svg?style=flat\u0026logo=powershell\u0026logoColor=white)\n![Docker](https://img.shields.io/badge/Docker-2496ED?style=flat\u0026logo=docker\u0026logoColor=white)\n![Windows](https://img.shields.io/badge/Windows-0078D6?style=flat\u0026logo=windows\u0026logoColor=white)\n\nA PowerShell-based utility for gracefully shutting down Docker containers with dependency awareness and visual progress tracking.\n\n## Files Explained\n\n### shutdownallcontainers.cmd\n\n```batch\n@echo off\nsetlocal EnableDelayedExpansion\ncolor 0B\n...\n```\n\nThis is the launcher script that:\n\n- Provides a user-friendly interface\n- Checks for required files and permissions\n- Executes the PowerShell script\n- Displays results\n\n### gracefully_shutdown_all_docker_containers.ps1\n\n```powershell\n# Function to show progress bar\nfunction Show-Progress {\n    param (\n        [string]$containerName,\n        [string]$status\n    )\n    ...\n}\n```\n\nThis is the main PowerShell script that handles:\n\n- Container dependency detection\n- Shutdown order calculation\n- Progress visualization\n- Graceful shutdown logic\n\n## How the PowerShell Script Works\n\n### Progress Bar Function\n\n```powershell\nfunction Show-Progress {\n    # Shows a progress bar like:\n    # [##########] 50% - container_name : Shutting down\n}\n```\n\nCreates a visual progress indicator for each container being shut down.\n\n### Container Dependencies\n\n```powershell\nfunction Get-ContainerDependencies {\n    # Detects dependencies through:\n    # 1. Network mode dependencies (--network container:name)\n    # 2. Container links (--link)\n    # 3. Docker Compose dependencies (depends_on)\n    # 4. Shared networks (containers in same non-default network)\n}\n```\n\nThe dependency detection system now includes:\n- Network-based dependency detection for containers sharing custom networks\n- Multi-network support for containers connected to multiple networks\n- Proper handling of Docker Compose relationships\n- Circular dependency detection and resolution\n\n### Shutdown Order\n\n```powershell\nfunction Get-ShutdownOrder {\n    # Uses topological sorting to determine\n    # safe shutdown order\n}\n```\n\nCalculates the correct order to shut down containers without breaking dependencies.\n\n### Main Execution\n\n```powershell\ntry {\n    # 1. Get dependencies\n    # 2. Calculate order\n    # 3. Show progress\n    # 4. Shut down containers\n}\n```\n\nOrchestrates the entire shutdown process.\n\n## Usage\n\n1. Place both files in the same directory\n2. Run `shutdownallcontainers.cmd`\n3. Watch the progress as containers are gracefully stopped\n\n## Example Output\n\n```\n+------------------------------------------------+\n|           Docker Graceful Shutdown Tool          |\n+------------------------------------------------+\n\nProcessing container: container1\n    [####################] 100% - container1 : Stopped\n```\n\n## Requirements\n\n- Windows OS\n- PowerShell 5.1+\n- Docker Desktop\n- Admin rights (recommended)\n\n## Tips\n\n- Keep both files together\n- Run as administrator\n- Default timeout is 30 seconds per container\n- Failed graceful shutdowns will attempt force stop\n\n## Error Handling\n\nThe script handles:\n\n- Missing files\n- Permission issues\n- Failed shutdowns\n- Circular dependencies\n\n## Support\n\nFor issues or questions:\n\n1. Check file permissions\n2. Verify Docker is running\n3. Run as administrator\n4. Check for circular dependencies\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on:\n- How to submit changes\n- How to report issues\n- Coding standards\n- Development process\n\n## Development Setup\n\n### Prerequisites for Development\n- Windows 10/11\n- PowerShell 5.1 or higher\n- Docker Desktop for Windows\n- Git\n- Your favorite code editor (VS Code recommended)\n\n### Development Environment Setup\n1. Clone the repository\n   ```bash\n   git clone https://github.com/PeterVinter/docker-graceful-shutdown-for-windows.git\n   cd docker-graceful-shutdown-for-windows\n   ```\n\n2. Set up PowerShell execution policy (if needed)\n   ```powershell\n   Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser\n   ```\n\n3. Test the scripts\n   ```cmd\n   shutdownallcontainers.cmd -test\n   ```\n\n### Code Style Guidelines\n- Use clear, descriptive variable names\n- Add comments for complex logic\n- Follow [PowerShell Best Practices](https://docs.microsoft.com/en-us/powershell/scripting/developer/cmdlet/cmdlet-development-guidelines)\n\n### Testing\nBefore submitting changes:\n1. Run the script with `-test` parameter\n2. Test with various container configurations\n3. Verify proper error handling\n4. Check script performance\n\n## Testing\n\nThe project includes comprehensive test coverage using Pester framework and GitHub Actions:\n- Automated testing on Windows environments\n- Safe and isolated test execution\n- Extensive test scenarios\n\nFor detailed testing information, see [tests/README.md](tests/README.md).\n\n## Examples\n\nThe `/examples` directory contains several scenarios demonstrating the utility's capabilities:\n\n1. Basic Web Stack ([examples/basic-web](examples/basic-web))\n   - Simple web application with database\n   - Basic network dependencies\n\n2. Microservices Architecture ([examples/microservices-example](examples/microservices-example))\n   - Multi-layer application architecture\n   - Complex network topology\n   - See directory README for details\n\n## Logging\n\nThe utility includes comprehensive logging functionality:\n\n- File-based logging in `./logs`\n- Console output with color-coding\n- Multiple log levels (INFO, WARNING, ERROR, DEBUG)\n\nEnable verbose logging:\n```powershell\n$VerbosePreference = 'Continue'\n.\\gracefully_shutdown_all_docker_containers.ps1\n```\n\nFor more details about logging configuration, see [modules/Logging.psm1](modules/Logging.psm1).\n\n## License\n\nMIT License - Feel free to modify and distribute\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetervinter%2Fdocker-graceful-shutdown-for-windows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetervinter%2Fdocker-graceful-shutdown-for-windows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetervinter%2Fdocker-graceful-shutdown-for-windows/lists"}