Repository navigation
Docker
- Overview
- Official Docker Images
- Quick Start
- Building Custom Images
- Docker Compose Setup
- Volume Management
- Multi-Container Patterns
- Kubernetes Deployment
- Health Checks
- Networking
- Troubleshooting
- Production Best Practices
- See Also
ExaBGP runs excellently in Docker containers, providing isolated, reproducible deployments. The official Docker image includes all necessary dependencies and follows container best practices.
Key Benefits:
- Isolation: Separate BGP processes per container
- Portability: Consistent deployment across environments
- Scalability: Easy horizontal scaling with orchestration
- Version Control: Pin specific ExaBGP versions
- Resource Limits: Control CPU/memory per instance
ExaBGP does NOT manipulate the routing table (RIB/FIB) - it only speaks the BGP protocol. Route installation must be handled by external processes or network devices.
The images are published on the GitHub Container Registry, not on Docker Hub.
# The latest release, 5.0.13
docker pull ghcr.io/exa-networks/exabgp:5.0.13
# The same image, and whichever 5.0 release comes next
docker pull ghcr.io/exa-networks/exabgp:5.0
# The latest tag
docker pull ghcr.io/exa-networks/exabgp:latestThe 5.0 releases have their own tags. There is no image for 4.x or for the main branch;
build one from the repository for those.
- Base: Python 3.13 slim-bookworm
- Size: ~150MB
-
User: the container starts as root, and ExaBGP changes to the user
exa(set asexabgp.daemon.userin the image's/opt/exabgp/etc/exabgp/exabgp.env) before starting its processes - Init: Uses dumb-init for proper signal handling
- Dependencies: iproute2 included
Create a configuration file exabgp.conf:
neighbor 192.168.1.1 {
router-id 10.0.0.1;
local-address 10.0.0.2;
local-as 65000;
peer-as 65001;
static {
route 203.0.113.1/32 next-hop self;
}
}Run ExaBGP:
docker run -d \
--name exabgp \
--network host \
-v $(pwd)/exabgp.conf:/etc/exabgp/exabgp.conf:ro \
ghcr.io/exa-networks/exabgp:latest \
/etc/exabgp/exabgp.confConfiguration with ExaBGP's built-in health checker as API process:
process health-check {
run exabgp healthcheck --cmd /usr/local/bin/health_check.py --ip 203.0.113.1/32 --no-ip-setup --withdraw-on-down;
encoder json;
}
neighbor 192.168.1.1 {
router-id 10.0.0.1;
local-address 10.0.0.2;
local-as 65000;
peer-as 65001;
api {
processes [ health-check ];
}
}The health checker runs health_check.py every 5 seconds, and announces 203.0.113.1/32 once the script has exited with 0 three times in a row, withdrawing it after three failures. The script only checks the service, as in Application Health Integration. ExaBGP in the image starts its processes as the unprivileged user exa, so --no-ip-setup stops the checker from trying to add the address to the loopback. The Healthcheck page describes every option.
Run with health check script:
docker run -d \
--name exabgp \
--network host \
-v $(pwd)/exabgp.conf:/etc/exabgp/exabgp.conf:ro \
-v $(pwd)/health_check.py:/usr/local/bin/health_check.py:ro \
ghcr.io/exa-networks/exabgp:latest \
/etc/exabgp/exabgp.confFROM ghcr.io/exa-networks/exabgp:latest
# Add custom health check scripts
COPY health_checks/ /opt/exabgp/health_checks/
RUN chmod +x /opt/exabgp/health_checks/*.py
# Add custom configuration
COPY exabgp.conf /etc/exabgp/exabgp.conf
# Install additional dependencies
USER root
RUN apt-get update && \
apt-get install -y curl netcat-openbsd && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER exa
ENTRYPOINT ["/usr/bin/dumb-init", "--", "exabgp"]
CMD ["/etc/exabgp/exabgp.conf"]Build:
docker build -t myorg/exabgp-custom:1.0 .# syntax=docker/dockerfile:1.4
FROM python:3.13-bookworm AS builder
# Install uv for fast builds
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
WORKDIR /build
# Copy ExaBGP source
COPY . /build/
# Build wheel
RUN uv build --wheel
# Install to /opt/exabgp
RUN pip install --target /opt/exabgp dist/*.whl
# Production image
FROM python:3.13-slim-bookworm
COPY --from=builder /opt/exabgp /opt/exabgp
ENV PYTHONPATH=/opt/exabgp
ENV PATH=/opt/exabgp/bin:$PATH
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y iproute2 dumb-init curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create ExaBGP user and directories
# (RUN uses /bin/sh, which does not expand exabgp.{in,out}: each name is written out)
RUN useradd -r -u 1000 exa && \
mkdir -p /etc/exabgp /run/exabgp /var/log/exabgp && \
mkfifo /run/exabgp/exabgp.in /run/exabgp/exabgp.out && \
chown -R exa:exa /etc/exabgp /run/exabgp /var/log/exabgp && \
chmod 600 /run/exabgp/exabgp.in /run/exabgp/exabgp.out
# Environment configuration: ExaBGP installed in /opt/exabgp reads
# /opt/exabgp/etc/exabgp/exabgp.env
RUN mkdir -p /opt/exabgp/etc/exabgp && \
echo "[exabgp.daemon]" > /opt/exabgp/etc/exabgp/exabgp.env && \
echo "user = 'exa'" >> /opt/exabgp/etc/exabgp/exabgp.env && \
echo "[exabgp.log]" >> /opt/exabgp/etc/exabgp/exabgp.env && \
echo "all = false" >> /opt/exabgp/etc/exabgp/exabgp.env && \
echo "configuration = true" >> /opt/exabgp/etc/exabgp/exabgp.env
USER exa
WORKDIR /etc/exabgp
ENTRYPOINT ["/usr/bin/dumb-init", "--", "exabgp"]
CMD ["--help"]version: '3.8'
services:
exabgp:
image: ghcr.io/exa-networks/exabgp:latest
container_name: exabgp
network_mode: host
restart: unless-stopped
volumes:
- ./config/exabgp.conf:/etc/exabgp/exabgp.conf:ro
- ./scripts:/opt/scripts:ro
- exabgp-logs:/var/log/exabgp
environment:
- exabgp_log_level=INFO
- exabgp_api_ack=true
command: /etc/exabgp/exabgp.conf
healthcheck:
test: ["CMD", "pgrep", "-f", "exabgp"]
interval: 30s
timeout: 10s
retries: 3
volumes:
exabgp-logs:version: '3.8'
services:
# ExaBGP Node 1
exabgp-node1:
image: ghcr.io/exa-networks/exabgp:latest
hostname: exabgp-node1
network_mode: host
restart: unless-stopped
volumes:
- ./config/node1.conf:/etc/exabgp/exabgp.conf:ro
- ./scripts/health_check.py:/opt/scripts/health_check.py:ro
- node1-logs:/var/log/exabgp
environment:
- NODE_ID=1
- SERVICE_IP=203.0.113.1
- PRIMARY_METRIC=100
command: /etc/exabgp/exabgp.conf
# ExaBGP Node 2
exabgp-node2:
image: ghcr.io/exa-networks/exabgp:latest
hostname: exabgp-node2
network_mode: host
restart: unless-stopped
volumes:
- ./config/node2.conf:/etc/exabgp/exabgp.conf:ro
- ./scripts/health_check.py:/opt/scripts/health_check.py:ro
- node2-logs:/var/log/exabgp
environment:
- NODE_ID=2
- SERVICE_IP=203.0.113.1
- PRIMARY_METRIC=101
command: /etc/exabgp/exabgp.conf
# Web service (example application)
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./html:/usr/share/nginx/html:ro
depends_on:
- exabgp-node1
- exabgp-node2
volumes:
node1-logs:
node2-logs:version: '3.8'
services:
exabgp:
image: ghcr.io/exa-networks/exabgp:latest
network_mode: host
restart: unless-stopped
volumes:
- ./config:/etc/exabgp:ro
- ./scripts:/opt/scripts:ro
command: /etc/exabgp/exabgp.conf
labels:
- "prometheus.scrape=true"
- "prometheus.port=9576"
# Prometheus exporter
exabgp-exporter:
image: lusis/exabgp_exporter:latest
ports:
- "9576:9576"
# ExaBGP has no network API: an exporter has to receive ExaBGP's
# messages as an ExaBGP process, see Prometheus Integration
depends_on:
- exabgp
# Prometheus
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
# Grafana
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- grafana-data:/var/lib/grafana
- ./monitoring/dashboards:/etc/grafana/provisioning/dashboards:ro
depends_on:
- prometheus
volumes:
prometheus-data:
grafana-data:Mount configuration as read-only:
docker run -d \
-v $(pwd)/exabgp.conf:/etc/exabgp/exabgp.conf:ro \
ghcr.io/exa-networks/exabgp:latestMount scripts directory with execute permissions:
docker run -d \
-v $(pwd)/scripts:/opt/scripts:ro \
-v $(pwd)/exabgp.conf:/etc/exabgp/exabgp.conf:ro \
ghcr.io/exa-networks/exabgp:latestEnsure scripts are executable:
chmod +x scripts/*.pyExaBGP writes its log on its standard error by default, which Docker keeps:
docker logs -f exabgpTo write it to a file instead, set exabgp_log_destination to a path the user exa can write to; ExaBGP opens the file after changing to that user.
The image includes ExaBGP's command line client, which talks to the running ExaBGP:
# image 5.0.x
docker exec exabgp exabgp cli announce route 203.0.113.1/32 next-hop selfExaBGP as sidecar to application:
services:
app:
image: myapp:latest
network_mode: "service:exabgp"
depends_on:
- exabgp
exabgp:
image: ghcr.io/exa-networks/exabgp:latest
hostname: app-bgp
ports:
- "179:179" # BGP port
volumes:
- ./config/exabgp.conf:/etc/exabgp/exabgp.conf:ro
- shared-scripts:/opt/scripts
command: /etc/exabgp/exabgp.conf
volumes:
shared-scripts:Multiple containers sharing network:
services:
exabgp:
image: ghcr.io/exa-networks/exabgp:latest
network_mode: host
volumes:
- ./exabgp.conf:/etc/exabgp/exabgp.conf:ro
haproxy:
image: haproxy:latest
network_mode: host
volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
- exabgpservices:
exabgp:
image: ghcr.io/exa-networks/exabgp:latest
environment:
- SERVICE_NAME=web
- SERVICE_IP=203.0.113.1
- CONSUL_ADDR=consul:8500
volumes:
- ./scripts/consul_discovery.py:/opt/scripts/discovery.py:ro
- ./exabgp.conf:/etc/exabgp/exabgp.conf:ro
consul:
image: consul:latest
ports:
- "8500:8500"services:
# FlowSpec controller
# ExaBGP has no network API: the controller has to give its commands
# to a process of ExaBGP, through a named pipe on a shared volume for
# example (see the FastNetMon page)
flowspec-controller:
image: myorg/flowspec-controller:latest
depends_on:
- exabgp
# ExaBGP FlowSpec announcer
exabgp:
image: ghcr.io/exa-networks/exabgp:latest
network_mode: host
volumes:
- ./flowspec.conf:/etc/exabgp/exabgp.conf:ro
command: /etc/exabgp/exabgp.conf
# DDoS detection (example)
fastnetmon:
image: fastnetmon/fastnetmon:latest
network_mode: host
environment:
- EXABGP_HOST=localhost
depends_on:
- exabgpSee Kubernetes for comprehensive Kubernetes integration documentation.
Quick Example:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: exabgp
namespace: bgp
spec:
selector:
matchLabels:
app: exabgp
template:
metadata:
labels:
app: exabgp
spec:
hostNetwork: true
containers:
- name: exabgp
image: ghcr.io/exa-networks/exabgp:latest
args: ["/etc/exabgp/exabgp.conf"]
volumeMounts:
- name: config
mountPath: /etc/exabgp
readOnly: true
volumes:
- name: config
configMap:
name: exabgp-configAdd to Dockerfile or docker-compose.yml:
HEALTHCHECK --interval=30s --timeout=10s --retries=3 \
CMD pgrep -f exabgp || exit 1More sophisticated health check:
#!/bin/bash
# health_check.sh
# Check if ExaBGP process is running
if ! pgrep -f "exabgp" > /dev/null; then
echo "ExaBGP process not running"
exit 1
fi
# Check if BGP session is established (requires netstat)
if ! netstat -tn | grep -q ":179.*ESTABLISHED"; then
echo "No established BGP sessions"
exit 1
fi
echo "ExaBGP healthy"
exit 0healthcheck:
test: ["/opt/scripts/health_check.sh"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40sMonitor application and announce via BGP. The script only checks the application and exits with 0 when it is healthy, and ExaBGP's health checker, given the script with --cmd as in With Health Check, announces or withdraws the route:
#!/usr/bin/env python3
# health_check.py
import sys
import urllib.request
def check_app_health():
try:
with urllib.request.urlopen('http://localhost:8080/health', timeout=2) as response:
return response.status == 200
except OSError:
return False
sys.exit(0 if check_app_health() else 1)The script uses the standard library only, because the image has no other Python package than ExaBGP.
When the decision needs logic the checker cannot express, Writing API Programs explains how to write your own program.
Recommended for BGP (needs direct access to network):
docker run -d --network host ghcr.io/exa-networks/exabgp:latestAdvantages:
- Direct access to host network interfaces
- BGP uses standard port 179
- No NAT/port mapping complexity
- Full routing table visibility
Considerations:
- Less isolation
- Containers share host network stack
- Port conflicts possible
For development/testing only:
docker run -d \
-p 179:179 \
--network bridge \
ghcr.io/exa-networks/exabgp:latestNot recommended for production - BGP requires proper network access.
# Create network
docker network create --driver bridge bgp-network
# Run ExaBGP
docker run -d \
--network bgp-network \
--name exabgp \
ghcr.io/exa-networks/exabgp:latestFor multiple BGP speakers with unique IPs:
# Create macvlan network
docker network create -d macvlan \
--subnet=192.168.1.0/24 \
--gateway=192.168.1.1 \
-o parent=eth0 \
bgp-macvlan
# Run with unique IP
docker run -d \
--network bgp-macvlan \
--ip 192.168.1.10 \
--name exabgp1 \
ghcr.io/exa-networks/exabgp:latestCheck logs:
docker logs exabgpCommon issues:
- Invalid configuration syntax
- Missing configuration file
- Port 179 already in use
- Permission issues
Debug networking:
# Check if BGP port is accessible
docker exec exabgp netstat -tlnp | grep 179
# Test connectivity to peer
docker exec exabgp ping -c 3 192.168.1.1
# Check routing table (if host network)
docker exec exabgp ip route
# Verify BGP process
docker exec exabgp ps aux | grep exabgpValidate configuration:
# Check configuration syntax (5.x image; ExaBGP 6.0 uses "configuration validate")
docker run --rm \
-v $(pwd)/exabgp.conf:/etc/exabgp/exabgp.conf:ro \
ghcr.io/exa-networks/exabgp:latest \
validate /etc/exabgp/exabgp.confCheck script permissions:
# Inside container
docker exec exabgp ls -la /opt/scripts/
# Should be executable (chmod +x)
chmod +x scripts/*.pyEnable verbose logging:
[exabgp.log]
all = true
destination = /var/log/exabgp/exabgp.logOr use environment variable:
docker run -d \
-e exabgp_log_level=DEBUG \
ghcr.io/exa-networks/exabgp:latestMonitor resources:
# Container stats
docker stats exabgp
# Set resource limits
docker run -d \
--memory="512m" \
--cpus="1.0" \
ghcr.io/exa-networks/exabgp:latest# Good
image: ghcr.io/exa-networks/exabgp:5.0.13
# Avoid
image: ghcr.io/exa-networks/exabgp:latestservices:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
read_only: true
tmpfs:
- /tmp
- /runservices:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256Mservices:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
restart: unless-stoppedservices:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"services:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
cap_add:
- NET_ADMIN # Only if needed
- NET_RAW# Store configs in git
git/
├── docker-compose.yml
├── config/
│ ├── exabgp.conf
│ └── exabgp.env
└── scripts/
├── health_check.py
└── announce.pyservices:
exabgp-test:
image: ghcr.io/exa-networks/exabgp:5.0.13
profiles: ["test"]
command: validate /etc/exabgp/exabgp.conf # 5.x image
volumes:
- ./config:/etc/exabgp:roRun tests:
docker compose --profile test up exabgp-testExaBGP serves no metrics itself: these labels describe the exporter process ExaBGP runs in the container, see Prometheus Integration:
services:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
labels:
- "prometheus.scrape=true"
- "prometheus.port=9576"
- "prometheus.path=/metrics"# Backup script
#!/bin/bash
docker exec exabgp cat /etc/exabgp/exabgp.conf > backup/exabgp.conf.$(date +%Y%m%d)Full production-ready docker-compose.yml:
version: '3.8'
services:
exabgp:
image: ghcr.io/exa-networks/exabgp:5.0.13
container_name: exabgp-prod
hostname: bgp-node1
network_mode: host
restart: unless-stopped
volumes:
- ./config/exabgp.conf:/etc/exabgp/exabgp.conf:ro
- ./config/exabgp.env:/etc/exabgp/exabgp.env:ro # read with --env-file, see command
- ./scripts:/opt/scripts:ro
- exabgp-logs:/var/log/exabgp
environment:
- NODE_ID=1
- CLUSTER=production
- REGION=us-east-1
healthcheck:
test: ["CMD", "/opt/scripts/health_check.sh"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "5"
labels: "service=exabgp"
security_opt:
- no-new-privileges:true
deploy:
resources:
limits:
cpus: '2.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M
labels:
- "com.example.service=exabgp"
- "com.example.environment=production"
- "prometheus.scrape=true"
- "prometheus.port=9576"
command: --env-file /etc/exabgp/exabgp.env /etc/exabgp/exabgp.conf
volumes:
exabgp-logs:
driver: local
driver_opts:
type: none
o: bind
device: /var/log/exabgp- Kubernetes Integration - Deploy ExaBGP on Kubernetes
- Prometheus Integration - Monitoring with Prometheus
- Cloud Platforms - AWS, GCP, Azure integration
- Configuration Syntax - ExaBGP configuration reference
- API Overview - Control ExaBGP via API
- High Availability - HA deployment patterns
- Debugging - Troubleshooting guide
- Official Docker Images - the images on the GitHub Container Registry
- Docker Documentation
- Docker Compose Documentation
- Facebook Katran - L4 load balancer whose VIPs Facebook announced with ExaBGP
Getting Started
Configuration
- Configuration Syntax
- Neighbor Configuration
- Directives A-Z
- Syntax Reference
- Templates
- Environment Variables
- Process Configuration
API
- API Overview
- Text API Reference
- JSON API Reference
- API Commands
- Writing API Programs
- Error Handling
- Production Best Practices
Address Families
- Overview
- IPv4 Unicast
- IPv6 Unicast
- FlowSpec
- EVPN
- L3VPN
- BGP-LS
- VPLS
- SRv6 / MUP
- Multicast
- RT Constraint
Features
Use Cases
Tools
Operations
Reference
- Architecture
- Design
- Attribute Reference
- Command Reference
- BGP State Machine
- Capabilities
- Communities
- Examples Index
- Glossary
- RFC Support
Integration
Migration
Community
External