NetBird can run inside Docker containers, enabling secure mesh networking for containerized applications. This is useful for connecting Docker containers across different hosts, accessing containers from your local machine, or integrating NetBird into CI/CD pipelines.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/netbirdio/netbird/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
Run NetBird in a Docker container:Docker Images
NetBird provides two Docker images:Standard Image
Image:
netbirdio/netbird:latest- Requires
NET_ADMIN,SYS_ADMIN, andSYS_RESOURCEcapabilities - Uses kernel WireGuard for better performance
- Full feature set
Rootless Image
Image:
netbirdio/netbird:latest-rootless- Runs as non-root user
- Uses userspace WireGuard (netstack)
- DNS disabled by default
- Suitable for restricted environments
Installation
Standard Container
- With Setup Key
- With Management URL
- Interactive Login
Rootless Container
For environments where elevated privileges are not available:The rootless image:
- Uses userspace WireGuard (slower than kernel WireGuard)
- Has DNS disabled by default (
NB_DISABLE_DNS=true) - Stores config in
/var/lib/netbirdinstead of/etc/netbird - Runs as user
netbird(non-root)
Docker Compose
Add NetBird to yourdocker-compose.yml:
Environment Variables
Configure NetBird using environment variables:Common Variables
| Variable | Description | Default | Example |
|---|---|---|---|
NB_SETUP_KEY | Setup key for authentication | - | A1B2C3D4E5F6... |
NB_MANAGEMENT_URL | Management server URL | https://api.netbird.io | https://netbird.example.com |
NB_HOSTNAME | Custom hostname for the peer | Auto-generated | docker-app-1 |
NB_LOG_LEVEL | Logging verbosity | info | debug, warn, error |
NB_LOG_FILE | Log file path | console,/var/log/netbird/client.log | console |
NB_INTERFACE_NAME | WireGuard interface name | wt0 | nb0 |
NB_WIREGUARD_PORT | WireGuard listening port | 51820 | 51821 |
Daemon Configuration
| Variable | Description | Default |
|---|---|---|
NB_DAEMON_ADDR | Daemon socket address | unix:///var/run/netbird.sock |
NB_CONFIG | Config file path | /etc/netbird/config.json |
NB_STATE_DIR | State directory | /var/lib/netbird |
Entrypoint Timing
| Variable | Description | Default |
|---|---|---|
NB_ENTRYPOINT_SERVICE_TIMEOUT | Seconds to wait for daemon startup | 5 |
NB_ENTRYPOINT_LOGIN_TIMEOUT | Seconds to wait for login check | 5 |
Rootless-Specific Variables
| Variable | Description | Default (Rootless) |
|---|---|---|
NB_USE_NETSTACK_MODE | Use userspace WireGuard | true |
NB_ENABLE_NETSTACK_LOCAL_FORWARDING | Enable local port forwarding | true |
NB_DISABLE_DNS | Disable DNS management | true |
NB_CONFIG | Config file path | /var/lib/netbird/config.json |
NB_DAEMON_ADDR | Daemon socket address | unix:///var/lib/netbird/netbird.sock |
Advanced Configuration
| Variable | Description |
|---|---|
NB_PRESHARED_KEY | WireGuard pre-shared key for additional security |
NB_EXTERNAL_IP_MAP | External IP to local IP/interface mapping |
NB_DNS_RESOLVER_ADDRESS | Custom DNS resolver address |
NB_DISABLE_AUTO_CONNECT | Disable automatic connection on startup |
NB_NETWORK_MONITOR | Enable network change monitoring |
NB_MTU | Set custom MTU for WireGuard interface |
Required Capabilities
Standard Image
The standard NetBird image requires these Linux capabilities:NET_ADMIN: Create and manage network interfaces (WireGuard)SYS_ADMIN: Mount and manage network namespacesSYS_RESOURCE: Adjust resource limits for WireGuard
--privileged unless absolutely necessary. The capabilities above are sufficient.
Rootless Image
The rootless image requires no special capabilities but has limited functionality:- Uses userspace WireGuard (lower performance)
- Cannot manage system DNS settings
- Cannot create kernel network interfaces
Networking Considerations
Host Network Mode
For optimal performance, consider using host networking:Custom Bridge Network
Connect NetBird to a custom Docker network:Exposing Ports
If you need to expose specific ports from the container:Volume Management
Persistent Storage
NetBird needs persistent storage for configuration and state:Backing Up Configuration
Checking Container Status
Advanced Use Cases
Kubernetes/K8s
Run NetBird as a sidecar or DaemonSet in Kubernetes:CI/CD Pipelines
Use NetBird in CI/CD to access private resources:Multi-Container Setup
Share NetBird network with other containers:Troubleshooting
Container fails to start
Container fails to start
Check if required capabilities are added:Verify setup key is set:
Cannot connect to peers
Cannot connect to peers
Check container logs:Verify NetBird status:Check WireGuard interface:
DNS not working
DNS not working
For standard image, check DNS configuration:For rootless image, DNS is disabled by default. Enable with:
Permission denied errors
Permission denied errors
Ensure required capabilities are added:For rootless environments, use the rootless image:
Enable Debug Logging
Best Practices
Use Named Volumes
Store configuration in named Docker volumes for easy backup and portability.
Set Restart Policy
Use
--restart unless-stopped to ensure NetBird survives container restarts.Use Environment Variables
Store sensitive data like setup keys in
.env files or secrets managers.Monitor Logs
Regularly check logs for connection issues or errors.