A sophisticated Gradio web application that converts Docker registry images into bootable disk images (.img files). This tool bridges the gap between containerized applications and traditional bootable systems.
- Web Interface: Beautiful, responsive Gradio interface with custom CSS styling
- Registry Support: Works with Docker Hub, private registries, and multi-platform images
- Authentication: Support for private registry credentials
- Multi-Architecture: Supports linux/amd64, linux/arm64, linux/386, and linux/arm/v7
- Flexible Output: Configurable disk image sizes from 512MB to 8GB
- Progress Tracking: Real-time conversion progress with detailed status updates
- Error Handling: Comprehensive error reporting and validation
- Docker Deployment: Containerized deployment with all dependencies included
- Registry Connection: Connects to the specified Docker registry using the DXF library
- Layer Download: Downloads all image layers for the specified platform
- Filesystem Assembly: Extracts and combines layers to create a complete root filesystem
- Disk Creation: Creates a disk image file with proper partitioning
- Bootloader Installation: Installs Linux kernel and GRUB bootloader
- Image Generation: Produces a bootable .img file ready for use
The easiest way to run the application is using Docker, which automatically handles all system dependencies:
# Clone or download the application files
# Then run with Docker Compose:
docker-compose up --build
# Access the application at http://localhost:7860Alternative Docker command:
docker build -t docker-to-bootable .
docker run -d --privileged -p 7860:7860 -v $(pwd)/output:/app/output docker-to-bootableIf you prefer to run natively on your system:
sudo apt-get update
sudo apt-get install -y parted grub-pc-bin grub-common kpartxpip3 install -r requirements.txtbash start_app.sh
# Or directly: python3 app.py-
Enter Docker Image URL:
- For Docker Hub:
alpine:latest,ubuntu:20.04,nginx:latest - For private registries:
registry.company.com/user/image:tag
- For Docker Hub:
-
Provide Credentials (if needed):
- Username and password for private registries
- Leave blank for public images
-
Select Platform:
- Choose target architecture (default: linux/amd64)
- Important for multi-architecture images
-
Set Disk Size:
- Minimum: 512MB
- Recommended: 2GB or larger
- Adjust based on image size and intended use
-
Convert:
- Click "Convert to Bootable Image"
- Monitor progress in real-time
- Download the generated .img file
| Image | Description | Recommended Size |
|---|---|---|
alpine:latest |
Minimal Linux distribution | 1GB |
debian:bullseye-slim |
Debian base system | 2GB |
ubuntu:20.04 |
Ubuntu LTS | 3GB |
centos:7 |
CentOS base | 2GB |
version: '3.8'
services:
docker-to-bootable:
build: .
ports:
- "7860:7860"
privileged: true
volumes:
- ./output:/app/output
restart: unless-stoppedapiVersion: apps/v1
kind: Deployment
metadata:
name: docker-to-bootable
spec:
template:
spec:
containers:
- name: docker-to-bootable
image: docker-to-bootable:latest
securityContext:
privileged: trueSee DOCKER_DEPLOYMENT.md for detailed deployment instructions.
The converter works best with images containing complete Linux userlands:
- ✅ Alpine Linux - Excellent support with APK package manager
- ✅ Debian/Ubuntu - Full support with APT package manager
- ✅ CentOS/RHEL - Good support with YUM/DNF
⚠️ Other distributions - May work with generic bootloader installation
The generated .img files can be used in several ways:
# QEMU
qemu-system-x86_64 -hda output.img -m 1024
# VirtualBox
# Import as a raw disk image# Write to USB drive (replace /dev/sdX with actual device)
sudo dd if=output.img of=/dev/sdX bs=4M status=progress- Upload to cloud providers that support custom images
- Convert to other formats (VMDK, VHD) using
qemu-img
-
docker_registry.py: Docker Registry API client- Handles authentication and image manifest parsing
- Downloads and extracts image layers
- Supports multi-platform images
-
image_converter.py: Bootable image creation- Disk partitioning and formatting
- Filesystem copying and kernel installation
- GRUB bootloader configuration
-
app.py: Gradio web interface- User input handling and validation
- Progress tracking and error reporting
- File download management
-
custom_style.css: Professional styling- Modern, responsive design
- Custom color scheme and animations
- Enhanced user experience
Docker Image → Registry API → Layer Download → Filesystem Assembly → Disk Creation → Bootloader Installation → Bootable Image
- Docker Engine 20.10+
- Docker Compose 2.0+
- 4GB RAM (recommended)
- 10GB free disk space
- Ubuntu 20.04+ or similar Linux distribution
- Python 3.8+
- Sudo privileges
- System packages:
parted,grub-pc-bin,grub-common,kpartx
"Permission denied" errors:
- Ensure the application runs with privileged access
- For Docker: use
--privilegedflag - For native: run with sudo privileges
"Image not found" errors:
- Verify the image URL is correct
- Check registry credentials for private images
- Ensure the specified platform is available
"Conversion failed" errors:
- Increase disk image size
- Check available disk space
- Verify the source image contains a complete Linux system
Container fails to start:
# Check logs
docker-compose logs docker-to-bootable
# Ensure privileged mode is enabled
docker run --privileged ...Loop device not available:
# Load loop module on host
sudo modprobe loop- Privileged Access: Required for disk operations and bootloader installation
- Registry Credentials: Handled securely, not logged or stored
- Temporary Files: Automatically cleaned up after conversion
- Input Validation: All user inputs are validated before processing
- Container Security: Use resource limits and network isolation in production
app.py- Main Gradio applicationdocker_registry.py- Docker Registry API clientimage_converter.py- Bootable image creation logiccustom_style.css- Web interface stylingDockerfile- Container build configurationdocker-compose.yml- Multi-container deploymentrequirements.txt- Python dependenciesstart_app.sh- Native startup scripttest_conversion.py- Test suiteREADME.md- This documentationDOCKER_DEPLOYMENT.md- Detailed Docker deployment guide
This application demonstrates advanced integration of:
- Docker Registry API interaction
- Linux system administration
- Web interface development
- File system manipulation
- Container orchestration
Feel free to extend the functionality or adapt for specific use cases.
This project is provided as-is with the Apache 2.0 license for practical use. Please ensure compliance with Docker image licenses and registry terms of service.