Added Big Bear Docker Cleanup Script V2

So a lot of things have changed in Verson 2.

  • Added verbose mode (-v or --verbose option)
    • Implemented a print_verbose() function to conditionally print detailed information
  • Implemented dry run mode (-d or --dry-run option)
    • Allows users to see what would be removed without actually deleting anything
  • Added error handling
    • Implemented a check_docker() function to ensure Docker is installed and running
  • Created a main() function
    • Improves code organization and readability
  • Added counters for cleanup statistics
    • CONTAINERS_REMOVED, IMAGES_REMOVED, VOLUMES_REMOVED, NETWORKS_REMOVED
  • Implemented a print_stats() function
    • Displays a summary of cleanup operations at the end of the script
  • Added confirmation step before executing cleanup
    • Prevents accidental deletions
  • Improved cleanup functions (cleanup_containers, cleanup_images, cleanup_volumes, cleanup_networks)
    • Now capture and store the number of resources removed or space reclaimed
  • Added fallback values for grep commands
    • Ensures variables are always set, even if no resources were removed
  • Added a --help option
    • Displays usage instructions and available options
  • Improved command-line argument parsing
    • Now handles -h and --help options
  • Added print_help() function
    • Provides users with information on how to use the script
  • Enhanced user feedback
    • More informative messages throughout the cleanup process
  • Improved code comments
    • Better documentation of script functionality
  • Standardized output formatting
    • Consistent use of echo statements and separators for better readability