ContainerNetwork AutoFix (CNAF) - Auto-recreates dependent containers
6.1K
Automatically recreates Docker containers that depend on a master container's network when the master container restarts. Designed for Unraid but works on any Docker host.
When using Docker's --net=container: networking mode (container networking), dependent containers reference the master container by its container ID. When the master container restarts (e.g., after an update), it gets a new container ID, breaking the network connection for all dependent containers.
Common scenario: You have containers routing through a VPN container (like GluetunVPN). When the VPN container updates and restarts, dependent containers lose network connectivity until manually recreated.
CNAF automates that process.
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 /usr/local/emhttp/plugins/dynamix.docker.manager/scripts:/scripts:ro \
-v /mnt/user/appdata/containernetwork-autofix:/var/log \
buxxdev/containernetwork-autofix:latest
All configuration is done via environment variables:
| Variable | Default | Description |
|---|---|---|
MASTER_CONTAINER | GluetunVPN | Name of the master container to monitor |
RESTART_WAIT_TIME | 15 | Seconds to wait after master restarts before recreating dependents |
MAX_LOG_LINES | 1000 | Maximum number of log lines to keep (automatic rotation) |
MAX_RETRIES | 10 | Number of times to retry finding master container on startup |
RETRY_DELAY | 10 | Seconds between retry attempts |
| Volume | Container Path | Description |
|---|---|---|
/var/run/docker.sock | /var/run/docker.sock | Access to Docker daemon |
/boot/config/plugins/dockerMan/templates-user | /templates | Unraid container templates |
/usr/local/emhttp/plugins/dynamix.docker.manager/scripts | /scripts | Unraid rebuild scripts |
| Volume | Container Path | Description |
|---|---|---|
/mnt/user/appdata/containernetwork-autofix | /var/log | Persistent log storage |
Route multiple containers through a VPN:
# qBittorrent routing through GluetunVPN
docker run -d \
--name=qBittorrent \
--net=container:GluetunVPN \
...
When GluetunVPN updates, CNAF automatically recreates qBittorrent with the new network reference.
Supported VPN Containers:
--net=container: modedocker ps | grep GluetunVPNls /boot/config/plugins/dockerMan/templates-user/my-CONTAINERNAME.xmlView real-time logs:
docker logs -f ContainerNetwork-AutoFix
View log file (if using persistent volume):
tail -f /mnt/user/appdata/containernetwork-autofix/containernetwork-autofix.log
--net=container: modeIssues and pull requests welcome!
Repository: https://github.com/buxxdev/containernetwork-autofix
MIT License - See LICENSE file
Created by @buxxdev to solve automatic container recreation when using network container dependencies on Unraid.
ContainerNetwork AutoFix (CNAF) - Keep your container networks healthy, automatically.
Content type
Image
Digest
sha256:3321dc9a2…
Size
14.9 MB
Last updated
11 months ago
docker pull buxxdev/containernetwork-autofix