On this page
- What does NetBox do and what does it need?
- How do you get netbox-docker?
- Which secrets must you change?
- How do you start NetBox and create the first user?
- How do you publish NetBox over HTTPS?
- How do you start modelling your network?
- How do you use the NetBox API?
- How do you configure mail, backups and upgrades?
- Questions
What does NetBox do and what does it need?
NetBox models your infrastructure: sites, racks, devices, cables, IP prefixes and addresses, VLANs, circuits and virtual machines, with a full REST and GraphQL API on top. Teams use it as the authoritative record that automation tools read from.
The Docker deployment runs NetBox, a background worker, a housekeeping job, PostgreSQL and two Redis instances. Give it at least 2 GB of memory; 4 GB is more comfortable once you import data or add plugins. Disk needs are small unless you attach many images to devices.
Prepare a sudo user (first SSH session), Docker with the Compose plugin (Docker Engine or the Docker image), git, and DNS records for netbox.example.net.
How do you get netbox-docker?
The community project keeps a release branch that always matches a tested NetBox version. Clone it into /opt:
sudo git clone -b release https://github.com/netbox-community/netbox-docker.git /opt/netbox-docker
sudo chown -R deploy: /opt/netbox-docker
cd /opt/netbox-docker
ls envThe env folder holds one file per service: netbox.env, postgres.env, redis.env and redis-cache.env. They ship with sample passwords that are public, so the next step is mandatory.
Which secrets must you change?
Generate fresh values and edit the files so that each pair matches:
openssl rand -hex 24 # database password
openssl rand -hex 24 # redis password
openssl rand -hex 24 # redis cache password
openssl rand -base64 60 | tr -d "\n=+/" # SECRET_KEYDB_PASSWORDinnetbox.envequalsPOSTGRES_PASSWORDinpostgres.env.REDIS_PASSWORDinnetbox.envequals the password inredis.env.REDIS_CACHE_PASSWORDinnetbox.envequals the password inredis-cache.env.SECRET_KEYmust be at least 50 characters and stay constant; changing it logs everyone out.
Also set CSRF_TRUSTED_ORIGINS=https://netbox.example.net in netbox.env so form posts through the proxy are accepted.
How do you start NetBox and create the first user?
The main Compose file does not publish any port. Add an override file that exposes the web container on the loopback address only:
cat > docker-compose.override.yml <<EOF
services:
netbox:
ports:
- "127.0.0.1:8000:8080"
EOF
docker compose pull
docker compose up -dThe first start runs database migrations and can take several minutes; docker compose ps shows the netbox service as healthy when it is ready. Then create an administrator:
docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
curl -sI http://127.0.0.1:8000/login/ | head -n 1The curl line should print an HTTP 200 status. The NetBox version appears in the footer of every page once you log in.
How do you publish NetBox over HTTPS?
Use Nginx with Certbot. On Ubuntu and Debian install nginx certbot python3-certbot-nginx with apt; on Rocky and Alma install epel-release, the same packages with dnf, and allow proxy connections with sudo setsebool -P httpd_can_network_connect 1. Create /etc/nginx/conf.d/netbox.conf:
server {
listen 80;
listen [::]:80;
server_name netbox.example.net;
client_max_body_size 25m;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
}sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d netbox.example.netAllow only web ports through the firewall: sudo ufw allow 80,443/tcp, or the http and https services with firewall-cmd on Rocky and Alma. A Caddy alternative is described in Caddy HTTPS.
How do you start modelling your network?
NetBox works best when you build from the top down. A practical order is:
- Create a site for each location, then racks inside it.
- Add manufacturers, device types and device roles; the community device type library offers ready definitions you can import.
- Create devices, their interfaces and the cables between them.
- Enter prefixes such as
198.51.100.0/24and2001:db8:4f2a::/48, then assign IP addresses to interfaces.
Bulk import accepts CSV, JSON or YAML on every list page, which saves time when you migrate from spreadsheets. Custom fields and tags cover data the core model does not include.
How do you use the NetBox API?
Create a token under your user profile, then call the REST API. Recent NetBox releases issue tokens that are sent as a Bearer header, while older tokens use the Token scheme; the token page shows which format yours needs.
TOKEN=paste-your-token
curl -s -H "Authorization: Token $TOKEN" -H "Accept: application/json" \
https://netbox.example.net/api/status/
curl -s -H "Authorization: Token $TOKEN" \
"https://netbox.example.net/api/ipam/prefixes/?limit=5"The status endpoint returns the NetBox, Python and plugin versions, which makes it a quick health check for monitoring. For scripting, the pynetbox Python library wraps the same API; see Python and pip for setting up a virtual environment.
How do you configure mail, backups and upgrades?
NetBox sends mail for error reports and some plugins. Set EMAIL_SERVER, EMAIL_PORT=587, EMAIL_USERNAME, EMAIL_PASSWORD, EMAIL_USE_TLS=true and EMAIL_FROM in netbox.env, pointing at an authenticated relay. Do not rely on port 25 being open outbound; ask support through a ticket before planning direct delivery.
Back up the database and uploaded media regularly:
cd /opt/netbox-docker
docker compose exec -T postgres pg_dump -U netbox netbox | gzip > ~/netbox-$(date +%F).sql.gz
docker run --rm -v netbox-docker_netbox-media-files:/m -v ~/:/b alpine tar czf /b/netbox-media-$(date +%F).tgz -C /m .To upgrade, update the branch, pull images and recreate; migrations run automatically:
git pull -p origin release
docker compose pull
docker compose up -dRead the NetBox release notes for major versions, which sometimes require a newer PostgreSQL. Check volume names with docker volume ls if the backup command reports a missing volume.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about NetBox network inventory
Is NetBox a monitoring tool?
Can I install NetBox without Docker?
Yes, the official documentation describes a native install with PostgreSQL, Redis, Python, Gunicorn and Nginx. Docker keeps upgrades simpler on a single server.
How do I add plugins?
Build a custom image from the netbox-docker Dockerfile that installs the plugin with pip, then list it in the plugins configuration. Test plugins against your NetBox version first.
Why do forms fail with a CSRF error?
CSRF_TRUSTED_ORIGINS does not include the exact HTTPS address users open, or the proxy does not pass the Host header.
Is LDAP or single sign-on supported?
NetBox supports LDAP and many SSO providers through its authentication settings. In the Docker setup these are configured through environment variables and extra config files.
More in Self-hosted apps
- Nextcloud on Nginx
- ownCloud Infinite Scale
- Seafile file sync
- Vaultwarden password vault
- Passbolt team password manager
- Gitea Git hosting
- Forgejo Git server
- GitLab Community Edition
- Gogs Git service
- Wiki.js
- BookStack documentation
- Outline knowledge base
- Paperless-ngx documents
- n8n workflow automation
- Activepieces automation
- Plausible Analytics (Community Edition)
- Umami analytics
- Mattermost team chat
- Matrix Synapse with Element
- Jitsi Meet video calls
- ONLYOFFICE Docs with Nextcloud
- HashiCorp Vault secrets server
- OpenBao secrets management
- Infisical secrets manager
- Authelia SSO and forward auth
- Zitadel identity platform
- VS Code in the browser (code-server)
- Joplin Server for notes sync
- Firefly III personal finance
- Snipe-IT asset tracking
- Odoo ERP on Ubuntu or Debian
- ERPNext with frappe_docker
- Dolibarr ERP and CRM with Nginx
- Penpot design tool with Docker
- Planka kanban boards
- Leantime project management
- Wekan boards with Docker
- Cal.com scheduling
- Chatwoot support inbox
- Mautic marketing automation
- DocuSeal document signing
- Metabase dashboards
- Appwrite backend server
- Self-hosted Supabase
- PocketBase backend
- RustDesk relay server
- Traccar GPS tracking
- Redmine project tracker
- The Lounge IRC client
- CyberChef data toolbox
- Typebot chat forms
- AFFiNE workspace
- Overleaf Community Edition
- Neko shared virtual browser
- imgproxy image resizing
- UVdesk help desk
- YetiForce CRM