-
Notifications
You must be signed in to change notification settings - Fork 5
dokploy_orphaned_volumes_cleanup.sh
Identifies and removes orphaned Docker volumes by scanning all containers and Docker Swarm services for volume usage.
Scans Docker containers and Swarm services to identify volumes that are not currently mounted or in use. Provides detailed information about orphaned volumes including size, creation date, and mount point. Can optionally remove orphaned volumes automatically to free up disk space.
Scans Docker containers and Swarm services to identify volumes that are not currently mounted or in use. Provides detailed information about orphaned volumes including size, creation date, and mount point. Can optionally remove orphaned volumes automatically to free up disk space.
- Docker installed and running
- Root/sudo access for volume inspection and removal
- Docker Swarm (optional, script works without it)
All configuration is hardcoded within the script.
AUTO_REMOVE - Set to true to automatically remove orphaned volumes, false for safe mode (list only)
- Default:
true - Type: Boolean
- Scans all Docker containers (running and stopped) for volume mounts
- Scans all Docker Swarm services for volume usage
- Compares all system volumes against used volumes
- Displays detailed information for each orphaned volume
- Optionally removes orphaned volumes if AUTO_REMOVE is true
- No secrets exposed in output
- Requires privileged access to Docker daemon
- Volume data is permanently deleted when removed
- 0 - Success
- 1 - Failure (error occurred)
===================================
Dokploy Orphaned Volumes Finder
===================================
Step 1: Scanning containers for volume usage...
✓ Scanned 15 containers
Step 2: Scanning Docker Swarm services for volume usage...
✓ Scanned 3 Swarm services
Step 3: Getting all volumes on system...
✓ Found 20 total volumes
✓ Found 18 volumes in use
Step 4: Identifying orphaned volumes...
Found 2 orphaned volume(s):
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Volume: old_app_data
Created: 2024-10-15 14:23:45
Driver: local
Size: 2.3G
Path: /var/lib/docker/volumes/old_app_data/_data
Status: ⚠️ NOT USED by any container or service
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
===================================
Removing 2 orphaned volumes...
Done!
- v1.0.0 (2024-11-18) - Initial release with Limehawk Style A formatting
- View Script Source
- Scripts - Back to script index