Enhance docker_cleanup.sh with logging and error handling

- Added error handling with 'set -e' to ensure the script exits on errors.
- Integrated logging functions for starting and completing the Docker cleanup process, improving visibility and tracking of script execution.
This commit is contained in:
Yury Kossakovsky
2025-08-06 10:43:09 -06:00
parent 4863f44c6e
commit 88575aaa43

View File

@@ -1,10 +1,15 @@
#!/bin/bash
set -e
# Source the utilities file
source "$(dirname "$0")/utils.sh"
# This script is intended for cleaning up the Docker system.
# It removes all unused containers, images, networks, and volumes.
# Use with caution, as this action is irreversible.
echo "Starting Docker cleanup..."
log_info "Starting Docker cleanup..."
# The 'docker system prune' command removes:
# - all stopped containers
@@ -19,5 +24,4 @@ echo "Starting Docker cleanup..."
docker system prune -a --volumes -f
echo "Docker cleanup completed successfully."
log_success "Docker cleanup completed successfully."