ContainerNetwork AutoFix (CNAF)Automatically recreates Docker containers when their master container restarts. The ProblemWhen using Docker's --net=container: networking (common with VPN containers), dependent containers reference the master container by its ID. When the master container restarts or updates, it gets a new container ID, breaking the network connection for all dependent containers. Example: You have containers routing through GluetunVPN. When GluetunVPN updates and restarts, your dependent containers (qBittorrent, Prowlarr, etc.) lose network connectivity and need to be manually recreated. The SolutionCNAF monitors your master container (VPN, etc.) and automatically recreates any dependent containers when it restarts, restoring their network connectivity. Features✅ Zero configuration - Automatically detects dependent containers ✅ State preservation - Maintains running/stopped state of containers ✅ Smart waiting - Configurable delay for VPN establishment ✅ Log rotation - Automatic log management ✅ Standalone - No dependencies on Unraid scripts ✅ Universal - Works with any master container (GluetunVPN, OpenVPN-Client, WireGuard, etc.) InstallationFrom Community Apps (Recommended)Open Community Apps Search for "ContainerNetwork AutoFix" or "CNAF" Click Install Configure the master container name (default: GluetunVPN) Apply Manual Installationbash docker run -d \ --name='ContainerNetwork-AutoFix' \ --restart=unless-stopped \ -e MASTER_CONTAINER='GluetunVPN' \ -e RESTART_WAIT_TIME='15' \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /boot/config/plugins/dockerMan/templates-user:/templates:ro \ -v /mnt/user/appdata/containernetwork-autofix:/var/log \ buxxdev/containernetwork-autofix:latest
```## Configuration| Variable | Default | Description ||----------|---------|-------------|| `MASTER_CONTAINER` | `GluetunVPN` | Name of the master container to monitor || `RESTART_WAIT_TIME` | `15` | Seconds to wait after master restarts (allows VPN to establish) || `MAX_LOG_LINES` | `1000` | Maximum log lines (automatic rotation) || `MAX_RETRIES` | `10` | Startup retry attempts for finding master container || `RETRY_DELAY` | `10` | Seconds between retry attempts |## How It Works1. CNAF starts and waits for your master container to be ready
2. Detects all containers using the master container's network
3. Monitors Docker events for master container restarts
4. When the master restarts:
- Waits for configured time (VPN establishment)
- Identifies containers using the old master container ID
- Records each container's state (running/stopped) - Stops and removes broken containers
- Recreates from Unraid templates
- Restores original state
## Common Use Cases### VPN Containers- **GluetunVPN** (most common)- OpenVPN-Client
- WireGuard
- NordVPN
- binhex-delugevpn
- Any VPN container using `--net=container:`### Example Setup```
GluetunVPN (master container)├── qBittorrent (--net=container:GluetunVPN)├── Prowlarr (--net=container:GluetunVPN)└── slskd (--net=container:GluetunVPN)When GluetunVPN restarts, CNAF automatically recreates qBittorrent, Prowlarr, and slskd. TroubleshootingContainer not being recreatedCheck the logs: bash docker logs ContainerNetwork-AutoFixVerify the container uses container networking: bash docker inspect YOUR_CONTAINER | grep NetworkModeShould show: "NetworkMode": "container:MASTER_CONTAINER_ID" "Master container not found"Ensure the master container name matches exactly (case-sensitive) Check the master container is running Increase MAX_RETRIES or RETRY_DELAY if the master takes time to start "Template not found"CNAF requires Unraid container templates to recreate containers Ensure containers were created through Unraid GUI (not manually via docker run) LinksGitHub: https://github.com/buxxdev/containernetwork-autofix Docker Hub: https://hub.docker.com/r/buxxdev/containernetwork-autofix Documentation: https://github.com/buxxdev/containernetwork-autofix/blob/main/README.md SupportPost questions or issues in this thread. Include: CNAF logs: docker logs ContainerNetwork-AutoFix Master container name Affected container names Unraid version Changelogv1.0.0 (2025-10-17) Initial release Auto-detection of dependent containers State preservation Log rotation Unraid template parsing