Overview
This document provides a comprehensive guide for recreating the Docker.img file on Unraid while preserving container configurations and custom networks. This process can be useful for maintenance, troubleshooting, or resizing the Docker virtual disk.
Prerequisites
- Administrative access to Unraid
- Basic understanding of Docker networking
- Terminal access to Unraid server
- Backup of critical data (recommended)
Important Notes
- This procedure will not result in data loss if followed correctly
- Container configurations will be preserved
- All custom networks will need to be recreated
Detailed Procedure
1. Document Custom Networks
Important: Complete this step before proceeding if you have custom networks.
Option A: If Docker is Running
docker network ls
Make note of all custom networks (excluding default networks like âbridgeâ, âhostâ, and ânoneâ).
Option B: If Docker is Not Running
Use the provided network discovery script (detailed in Section V).
2. Stop Docker Service
- Navigate to Settings > Docker
- Set âEnable Dockerâ to âNoâ
- Click âApplyâ
3. Backup (Optional but Recommended)
# Using terminal
cp /mnt/user/system/docker/docker.img /mnt/user/backups/docker.img.bak
# Alternative: Use Unraid's file manager to create a backup
4. Remove Existing Docker.img
- In Settings > Docker:
- Enable âDelete VDISK fileâ
- Click âApplyâ
- Verify the docker.img file is removed
5. Optional Cleanup
- Navigate to Apps > Previous Apps
- Review and remove unnecessary containers
- Document any specific container configurations you wish to preserve
6. Reinitialize Docker
- Return to Settings > Docker
- Set âEnable Dockerâ to âYesâ
- Configure desired vdisk size (if changing)
- Click âApplyâ
7. Recreate Custom Networks
For each custom network previously documented:
docker network create <network_name>
8. Restore Containers
- Navigate to Apps > Previous Apps
- Select desired containers for reinstallation
- Click âInstall Selectedâ
- Monitor the installation progress
9. Verify Installation
- Check container status
- Verify network connectivity
- Test container functionality
- Review logs for any errors
V. Custom Network Discovery Script
Use this script if Docker is unavailable and you need to identify custom networks.
#!/bin/bash
# Configuration
OUTPUT_FILE="/mnt/user/data/docker_networks.txt"
INPUT_DIR="/boot/config/plugins/dockerMan/templates-user"
# Clear existing output
> "$OUTPUT_FILE"
# Process XML files and extract network information
for file in "$INPUT_DIR"/*.xml; do
grep -oP '(?<=<Network>).*?(?=</Network>)' "$file" | \
grep -v "host" | \
grep -v "bridge" | \
grep -v "br0" | \
grep -v "container:" \
done | sort | uniq > "$OUTPUT_FILE"
echo "Network information exported to $OUTPUT_FILE"
Script Usage
- Save the script with a
.shextension - Make it executable:
chmod +x script_docker.sh - Run the script:
./script_docker.sh - Check the output file for custom network names
Troubleshooting
Common Issues
-
Container Wonât Start
- Verify network assignments
- Check container logs
- Confirm port mappings
-
Missing Networks
- Review network discovery script output
- Check container network dependencies
- Verify network creation commands
-
Configuration Issues
- Compare against documented settings
- Review container templates
- Check volume mappings
Best Practices
- Always backup before starting
- Document all custom configurations
- Take screenshots of critical settings
- Test container functionality after restoration
- Maintain detailed network documentation
- Regular maintenance and cleanup
Support
For additional assistance:
- Consult Unraid forums
- Review Docker documentation
- Check container-specific documentation
Version Information
- Last Updated: 2024
- Tested on: Unraid 6.x
- Docker version: 20.x and later