|
1 |
| -# Docker Container Manager |
2 |
| - |
3 |
| -A set of shell scripts to manage Docker containers with proper shutdown and startup handling, including dependency management. |
4 |
| - |
5 |
| -## Requirements |
6 |
| - |
| 1 | +# Docker Safe Shutdown |
| 2 | + |
| 3 | +[](https://github.com/PeterVinter/docker-safe-shutdown/releases) |
| 4 | +[](https://github.com/PeterVinter/docker-safe-shutdown/blob/main/LICENSE) |
| 5 | +[](https://github.com/PeterVinter/docker-safe-shutdown/issues) |
| 6 | +[](https://github.com/PeterVinter/docker-safe-shutdown/stargazers) |
| 7 | +[](https://github.com/PeterVinter/docker-safe-shutdown/network) |
| 8 | +[](../../actions/workflows/ci.yml) |
| 9 | +[](https://github.com/PeterVinter/docker-safe-shutdown/graphs/commit-activity) |
| 10 | +[](https://www.gnu.org/software/bash/) |
| 11 | +[](https://hub.docker.com/r/PeterVinter/docker-safe-shutdown) |
| 12 | +[](https://hub.docker.com/r/PeterVinter/docker-safe-shutdown) |
| 13 | +[](https://codecov.io/gh/PeterVinter/docker-safe-shutdown) |
| 14 | +[](https://github.com/PeterVinter/docker-safe-shutdown/actions?query=workflow%3AShellCheck) |
| 15 | +[](https://github.com/PeterVinter/docker-safe-shutdown/commits/main) |
| 16 | +[](https://github.com/PeterVinter/docker-safe-shutdown/graphs/contributors) |
| 17 | +[](https://makeapullrequest.com) |
| 18 | +[](https://hits.seeyoufarm.com) |
| 19 | + |
| 20 | +A robust solution for safely shutting down and starting up Docker containers on Linux systems. |
| 21 | + |
| 22 | +## Features |
| 23 | + |
| 24 | +- Safe shutdown of Docker containers with proper cleanup |
| 25 | +- Automatic container startup on system boot |
| 26 | +- Detailed logging of shutdown and startup processes |
| 27 | +- Configurable shutdown timeouts |
| 28 | +- Error handling and recovery |
| 29 | + |
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +- Linux operating system |
7 | 33 | - Docker installed and running
|
8 | 34 | - Bash shell
|
9 |
| -- Works on both Ubuntu and macOS |
| 35 | +- Root or sudo privileges |
10 | 36 |
|
11 | 37 | ## Installation
|
12 | 38 |
|
13 |
| -1. Clone or download these scripts to your server |
| 39 | +1. Clone the repository: |
| 40 | +```bash |
| 41 | +git clone https://github.com/PeterVinter/docker-safe-shutdown.git |
| 42 | +cd docker-safe-shutdown |
| 43 | +``` |
| 44 | + |
14 | 45 | 2. Make the scripts executable:
|
15 |
| - ```bash |
16 |
| - chmod +x start.sh docker_safe_shutdown.sh startup_docker_container.sh |
17 |
| - ``` |
| 46 | +```bash |
| 47 | +chmod +x *.sh |
| 48 | +``` |
18 | 49 |
|
19 | 50 | ## Usage
|
20 | 51 |
|
21 |
| -Run the main menu script: |
| 52 | +### Starting Containers |
22 | 53 | ```bash
|
23 |
| -./start.sh |
| 54 | +./startup_docker_container.sh |
24 | 55 | ```
|
25 | 56 |
|
26 |
| -The menu provides the following options: |
| 57 | +### Shutting Down Containers |
| 58 | +```bash |
| 59 | +./docker_safe_shutdown.sh |
| 60 | +``` |
27 | 61 |
|
28 |
| -1. **Shutdown Docker Containers** |
29 |
| - - Safely stops all running containers |
30 |
| - - Preserves container configuration for restart |
31 |
| - - Handles dependencies in correct order |
| 62 | +## Configuration |
32 | 63 |
|
33 |
| -2. **Start Docker Containers** |
34 |
| - - Starts previously shutdown containers |
35 |
| - - Restores original configuration |
36 |
| - - Handles containers in correct dependency order |
| 64 | +The scripts can be configured by modifying the following variables in the respective scripts: |
37 | 65 |
|
38 |
| -3. **View Shutdown Log** |
39 |
| - - Shows the shutdown_logs.txt file |
40 |
| - - Contains timestamps and container shutdown information |
| 66 | +- `TIMEOUT`: Maximum time to wait for container shutdown |
| 67 | +- `LOG_FILE`: Location of log files |
| 68 | +- `CONTAINER_LIST`: List of containers to manage |
41 | 69 |
|
42 |
| -4. **View Startup Log** |
43 |
| - - Shows the startup_logs.txt file |
44 |
| - - Contains timestamps and container startup information |
| 70 | +## Logging |
45 | 71 |
|
46 |
| -5. **List Running Containers** |
47 |
| - - Shows all currently running containers |
48 |
| - - Displays names, images, and status |
| 72 | +Logs are stored in: |
| 73 | +- `startup_logs.txt`: Container startup logs |
| 74 | +- `shutdowns_logs.txt`: Container shutdown logs |
| 75 | +- `shutdowned.txt`: Status of shutdown containers |
49 | 76 |
|
50 |
| -6. **List Stopped Containers** |
51 |
| - - Shows all stopped containers |
52 |
| - - Displays names, images, and when they were stopped |
| 77 | +## Contributing |
53 | 78 |
|
54 |
| -7. **Exit** |
55 |
| - - Exits the program |
| 79 | +Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests. |
56 | 80 |
|
57 |
| -## Files |
| 81 | +## License |
58 | 82 |
|
59 |
| -- `start.sh`: Main menu script |
60 |
| -- `docker_safe_shutdown.sh`: Handles container shutdown |
61 |
| -- `startup_docker_container.sh`: Handles container startup |
62 |
| -- `shutdowns_logs.txt`: Log file for shutdown operations |
63 |
| -- `startup_logs.txt`: Log file for startup operations |
64 |
| -- `shutdowned.txt`: Stores container configurations for restart |
| 83 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
65 | 84 |
|
66 |
| -## Notes |
| 85 | +## Support |
67 | 86 |
|
68 |
| -- The scripts automatically detect the operating system (Ubuntu/macOS) and use appropriate commands |
69 |
| -- All operations are logged with timestamps |
70 |
| -- Container configurations are preserved during shutdown |
71 |
| -- Dependencies are handled automatically based on network connections |
| 87 | +If you encounter any problems or have suggestions, please [open an issue](../../issues/new). |
0 commit comments