-
Notifications
You must be signed in to change notification settings - Fork 138
document NETBIRD_DOCKER_SUBNET and the Docker network conflict check #919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,26 @@ NetBird uses two types of environment variables: | |
| 1. **Setup Variables** (`NETBIRD_` prefix) - Used in docker-compose templates and `setup.env` for initial configuration | ||
| 2. **Runtime Variables** (`NB_` prefix) - Can override CLI flags at runtime using the pattern `--flag-name` → `NB_FLAG_NAME` | ||
|
|
||
| ## Installation Script Variables | ||
|
|
||
| These are read from the shell environment by the install and migration scripts (`getting-started.sh`, `getting-started-enterprise.sh`, `migrate.sh`), not from `setup.env`. Pass them on the command line when you run the script. | ||
|
|
||
| | Variable | Default | Description | | ||
| |----------|---------|-------------| | ||
| | `NETBIRD_DOCKER_SUBNET` | `172.30.0.0/24` | The `/24` used for the generated Docker bridge network. The gateway (`.1`) and Traefik's static address (`.10`) are derived from it, along with the trusted-proxy pins in the generated server configuration. | | ||
|
|
||
| ```bash | ||
| curl -fsSL https://github.com/netbirdio/netbird/releases/latest/download/getting-started.sh | NETBIRD_DOCKER_SUBNET=10.123.45.0/24 bash | ||
| ``` | ||
|
|
||
| The value must be a `/24` ending in `.0`. `0.0.0.0/8`, `127.0.0.0/8`, `169.254.0.0/16`, `224.0.0.0` and above, and `100.64.0.0/10` are rejected — the last because NetBird assigns overlay peer addresses from that range, so a Docker bridge there would shadow your NetBird network. | ||
|
|
||
| Before writing any files, the scripts check the existing Docker networks and stop with an actionable error if one overlaps the chosen subnet, instead of failing later during `docker compose up`. Existing networks are never modified. Host routes such as LANs and VPN tunnels are not inspected — use this variable if the default range collides with one of those. | ||
|
Comment on lines
+30
to
+32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Qualify the “before writing any files” claim.
🤖 Prompt for AI Agents |
||
|
|
||
| <Note> | ||
| If a run stops on a network conflict, see [Script exits with a Docker network conflict](/selfhosted/troubleshooting/installation#script-exits-with-a-docker-network-conflict). | ||
| </Note> | ||
|
|
||
| ## Core Setup Variables | ||
|
|
||
| These variables are set in your `setup.env` file before running the configuration script. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,7 +62,7 @@ The script runs through four phases automatically: | |
|
|
||
| The script operates in one of two modes depending on your detected reverse proxy: | ||
|
|
||
| **Automatic (embedded Caddy setups).** If your old deployment uses the embedded Caddy proxy (the default from `configure.sh` or `getting-started.sh`), the script performs the full migration end-to-end. It stops old containers, generates a Traefik-based `docker-compose.yml`, and starts the new stack. The generated compose file creates a Docker network (`172.30.0.0/24`) with Traefik at `172.30.0.10`, and reuses your existing management volume if detected. | ||
| **Automatic (embedded Caddy setups).** If your old deployment uses the embedded Caddy proxy (the default from `configure.sh` or `getting-started.sh`), the script performs the full migration end-to-end. It stops old containers, generates a Traefik-based `docker-compose.yml`, and starts the new stack. The generated compose file creates a Docker network — `172.30.0.0/24` by default, with Traefik at `172.30.0.10` — and reuses your existing management volume if detected. Set [`NETBIRD_DOCKER_SUBNET`](#environment-variables) if that range is already in use on your host. | ||
|
|
||
| **Manual (external proxy setups).** If your deployment uses a custom or external reverse proxy (Nginx, HAProxy, etc.), the script generates the configuration files but does **not** stop or start any containers. You must handle the cutover yourself, including updating your proxy routing rules. | ||
|
|
||
|
|
@@ -174,6 +174,22 @@ curl -sk -o /dev/null -w '%{http_code}' https://your-domain/api/accounts | |
| | `--non-interactive` | Skip all confirmation prompts. Useful for automation and CI pipelines. | | ||
| | `-h`, `--help` | Display usage information and exit. | | ||
|
|
||
| ### Environment variables | ||
|
|
||
| | Variable | Default | Description | | ||
| |---|---|---| | ||
| | `NETBIRD_DOCKER_SUBNET` | `172.30.0.0/24` | The `/24` used for the generated Docker network. Traefik takes `.10` and the gateway `.1`. Must end in `.0`; `0.0.0.0/8`, `127.0.0.0/8`, `169.254.0.0/16`, `224.0.0.0` and above, and `100.64.0.0/10` are rejected. | | ||
|
|
||
| ```bash | ||
| NETBIRD_DOCKER_SUBNET=10.123.45.0/24 ./migrate.sh --install-dir /opt/netbird | ||
| ``` | ||
|
|
||
| Validation runs during preflight, so an invalid value fails before anything on the host is touched. The overlap check against existing Docker networks runs after the old containers are stopped, since `compose down` releases the old deployment's own network first. | ||
|
|
||
| <Note> | ||
| The migration script carries the `reverseProxy` trust pins over from your old `management.json` unchanged. If that configuration already pinned an address inside `172.30.0.0/24`, overriding the subnet will not rewrite the pin — review `config.yaml` after the migration. | ||
| </Note> | ||
|
Comment on lines
+177
to
+191
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift Keep The shared reference says the variable derives the pins, but the migration page says
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Script exits with "External IdP detected" | ||
|
|
@@ -188,6 +204,28 @@ This means the installation directory already contains a `config.yaml` file, whi | |
| mv config.yaml config.yaml.bak | ||
| ``` | ||
|
|
||
| ### Script exits with a Docker network conflict | ||
|
|
||
| The script stops if an existing Docker network overlaps the subnet it is about to use, or if a leftover NetBird network sits on a different subnet than the one being generated. Both checks happen before the new `docker-compose.yml` is written. | ||
|
|
||
| Because this check runs after the old containers are stopped, the old deployment is down at that point. The error output includes the rollback command to bring it back: | ||
|
|
||
| ```bash | ||
| bash <backup-dir>/rollback.sh | ||
| ``` | ||
|
Comment on lines
+213
to
+215
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use shell-safe placeholders in the commands.
Also applies to: 223-227 🤖 Prompt for AI Agents |
||
|
|
||
| Then either pick a free `/24` and re-run: | ||
|
|
||
| ```bash | ||
| NETBIRD_DOCKER_SUBNET=10.123.45.0/24 ./migrate.sh --install-dir /opt/netbird | ||
| ``` | ||
|
|
||
| Or, if the reported network belongs to the old NetBird deployment and is no longer in use, remove it and re-run: | ||
|
|
||
| ```bash | ||
| docker network rm <network-name> | ||
| ``` | ||
|
|
||
| ### Script cannot detect the installation directory | ||
|
|
||
| If the script cannot find `management.json` in any of the default locations (`$PWD`, `/opt/netbird`, `/opt/wiretrustee`), use the `--install-dir` flag to specify the path explicitly: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,38 @@ A valid response is JSON containing `"issuer"`. Anything else points to where to | |
|
|
||
| **Confirm**: The probe succeeds and the script continues on its own. You can leave it waiting while you debug. To start over instead, stop it with Ctrl+C, run `docker compose down -v`, fix the issue, and re-run. | ||
|
|
||
| ## Script exits with a Docker network conflict | ||
|
|
||
| **Symptom**: The script stops before generating any files, with one of these two errors: | ||
|
|
||
| ``` | ||
| ERROR: the existing Docker network 'some-network' (172.30.0.0/16) overlaps 172.30.0.0/24, the subnet NetBird would use. | ||
| ``` | ||
|
|
||
| ``` | ||
| ERROR: the Docker network 'netbird_netbird', left over from a previous NetBird install, uses 172.16.0.0/24 instead of 172.30.0.0/24. | ||
| ``` | ||
|
|
||
| **Cause**: NetBird's Compose network defaults to `172.30.0.0/24`. The script checks this up front so you get a clear error here rather than a `Pool overlaps with other one on this address space` failure later in `docker compose up`. | ||
|
|
||
| The first error means an unrelated Docker network already covers that range. The second means a network from an earlier NetBird install is still present on a *different* subnet — Compose would reuse it as-is, and the generated configuration would not match it. | ||
|
|
||
| **Fix**: For the first error, pick a free `/24` and re-run. The conflicting network belongs to something else, so the script never touches it: | ||
|
|
||
| ```bash | ||
| NETBIRD_DOCKER_SUBNET=10.123.45.0/24 ./getting-started.sh | ||
| ``` | ||
|
Comment on lines
+72
to
+76
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Make the rerun command match the installation flow. The quickstart downloads 🤖 Prompt for AI Agents |
||
|
|
||
| For the second error, remove the stale NetBird network and re-run: | ||
|
|
||
| ```bash | ||
| docker network rm netbird_netbird | ||
| ``` | ||
|
|
||
| The subnet must be a `/24` ending in `.0`. See [Installation Script Variables](/selfhosted/environment-variables#installation-script-variables) for the full list of rejected ranges, including `100.64.0.0/10`, which NetBird uses for overlay peer addresses. | ||
|
|
||
| **Confirm**: Re-run the script; it proceeds past the network check and starts provisioning. Verify the result with `docker network inspect <project>_netbird`, which should report the subnet you chose. | ||
|
|
||
|
Comment on lines
+78
to
+87
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use the network name reported by the script. The command hard-codes 🤖 Prompt for AI Agents |
||
| ## Script fails on existing installation check | ||
|
|
||
| **Symptom**: The script exits immediately with a message about generated files already existing. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Use “default” instead of “fixed”.
NETBIRD_DOCKER_SUBNETmakes the subnet configurable. The current wording conflicts with the override documented in Line 275. Use “deterministic subnet” or “default subnet”.🧰 Tools
🪛 LanguageTool
[grammar] ~274-~274: Ensure spelling is correct
Context: ...t so you get a clear error instead of a
Pool overlaps with other one on this address spacefailure duri...(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents