GuidesNetwork and VPNNetwork docs with NetBox

Document your network with NetBox and rootless Docker

NetBox 4.7 on Debian 13, the open-source source of truth for networks and server rooms, in rootless Docker with PostgreSQL and Valkey under a user of its own behind Caddy, with sites, racks, cables, IP addresses, an API and backups.

Tested on Docker steps follow the tested rootless Docker base guide on Debian 13 with Docker Engine 29.10.1, Compose 5.8.1 and rootlesskit 3.3.0; the app version and app-specific behaviour are from the tested Podman guide on a Melonslab server. Not re-tested end to end under Docker. Updated November 28, 2026

Recommended server for this guide

SSD RAID 1 · ECC DDR4 · 10 Gbit

VC-P Alloy · 2 vCPU · 8 GB Memory · 60 GB Storage

Month to month, no lock-in 7-day money-back guarantee

These steps were tested on VC-P Titanium. This uses so little that VC-P Alloy, with the same number of vCPUs and memory on an older CPU, is enough at a small scale and costs less.

€8.99/mo

Deploy now

Quick install on a fresh VM

This command sets up a rootless container engine and a directory for this service. Podman is the default; add --engine docker to the command to use Docker instead.

curl -fsSL https://www.melonslab.com/install/rootless.sh | bash -s -- --app netbox-docker --manifest netbox --sha256 c73fd7fec5f024060136e28af7924426002b916e9e4bc5abe73efe8b697563ed
View the script

SHA-256: 97785be3e3e91393181a4a7caeab5f4b52803bf52e960dd488945cb38c6473a2

Run this guide on Melonslab

We ran every step below on our own server. For this workload we recommend VC-P Alloy at €8.99/mo. Order it, pick Debian 13, and follow the guide.

  1. 1. Order the server. Use the button below to order the recommended plan. Choose Debian 13 when the installer asks for an operating system.
  2. 2. Add IPv4 if needed. Add it on the order form when the guide publishes a service on the internet. It is a paid add-on, not included in the plan.
  3. 3. Connect over SSH. Log in as root with the address and credentials from your order, then run the commands below.
  4. 4. Follow the verified steps. Every command in this guide was run on a Melonslab server before it was published.
Deploy now
On this page

What you will set up

The Docker steps below follow our tested rootless Docker guide. The app version and the app-specific results come from the tested Podman guide on a Melonslab server; they were not measured under Docker, and this app was not re-tested end to end with Docker.

NetBox keeps track of what your network and server rooms contain and how it fits together: sites, racks and what is mounted where, devices and their interfaces, the cables between them, and the IP addresses, prefixes and VLANs in use. It is meant to be the one place where that is written down, the source of truth that people look things up in and scripts read from, instead of spreadsheets that drift apart. Everything is in a web interface and in a REST API, and every change is logged.

NetBox was started by Jeremy Stretch at DigitalOcean and published as open source in 2016. Today it is developed in the open on GitHub by NetBox Labs, an American company, with its community. NetBox itself is open source under the Apache 2.0 licence, with no feature limits. NetBox Labs sells two things on top, checked on netboxlabs.com on 14 October 2026: NetBox Cloud, which is NetBox run by them, with a free plan for up to 100 devices and 500 IP addresses and without plugins, webhooks or custom scripts, and paid plans with SSO, backups and support; and NetBox Enterprise, which you run yourself, with an installer, built-in backup and restore, single sign-on, certified plugins, support, and an Air Gap edition for networks without internet access. They also sell separate products that work with NetBox: Discovery, which finds devices on your network, Assurance, which compares the network with what NetBox says, and Copilot, an AI assistant that runs as their cloud service. None of that is needed for what this guide does.

NetBox Labs publish no container image of their own. This guide uses the one from the netbox-docker project, run by volunteers in the netbox-community organisation on GitHub, also under Apache 2.0. Its tag v4.7 follows every NetBox 4.7 release.

NetBox needs PostgreSQL for its data, and Redis for its task queue and cache. Its documentation asks for Redis 6.0 or later and does not mention Valkey, the open-source fork of Redis, but netbox-docker ships with Valkey and that is what this guide uses. It worked throughout our tests.

Here NetBox runs as a Compose project under a user of its own called netbox, with four containers: PostgreSQL, Valkey, NetBox's web server, and a worker that runs background jobs such as webhooks. Earlier versions of netbox-docker had a fifth, housekeeping container; NetBox now does that itself, as a daily job in the worker. Caddy from the Docker guide is in front.

In the Podman test, on a fresh Melonslab VC-P Titanium (4 vCPU, 16 GB) with Debian 13:

  • NetBox 4.7.3 started with PostgreSQL 18 and Valkey 9.1. The first admin was created and tested over an SSH tunnel before Caddy was set up.
  • Without a login, every page sent visitors to the login page, uploaded images too, and the API answered 403.
  • A site, a rack, three devices with interfaces from imported device types, two cables, a VLAN, a prefix and IP addresses were created, in the web interface and by CSV and YAML import. NetBox showed the next free address, and the API handed it out.
  • A colleague in a read-only group could see everything in the inventory, and got 403 when trying to change anything.
  • An API token worked from outside. A token limited to certain addresses was refused from others, also when the request claimed another address, once Caddy set the header as in step 5.
  • An event rule sent a webhook for each new IP address.
  • A capture of the server's traffic showed NetBox contacting NetBox Labs for usage statistics, news and the plugin list. With ISOLATED_DEPLOYMENT=true it made no outside connections at all, while webhooks still went out.
  • The Topology Views plugin was built into the image and drew the devices and cables.
  • An update from NetBox 4.6.10 to 4.7.3 ran its database migrations in about three minutes. NetBox was restored from a backup for a new user, with the same data, users, images and API tokens, and everything came back by itself after a reboot.

In the Podman test, the Compose project used about 1.5 GB of memory, most of it the four web server processes.

Before you start

You need:

  • a server set up as in the Docker guide, with Caddy running;
  • an A record and an AAAA record for netbox.example.com pointing at your server.

The examples use netbox.example.com for NetBox, 203.0.113.10 for your server's IPv4 address, anna for your own account and erik for a colleague. Replace them throughout.

1. Create the user

As root:

useradd -m -s /bin/bash -U netbox
loginctl enable-linger netbox
uid=$(id -u netbox)

Steps 2 to 16 use the runuser commands shown below, as netbox, from /home/netbox/netbox.

2. Create the secrets

umask 077
mkdir -p /home/netbox/netbox/secrets
openssl rand -base64 48 | tr -d '\n' > /home/netbox/netbox/secrets/secret_key
openssl rand -base64 48 | tr -d '\n' > /home/netbox/netbox/secrets/api_token_pepper_1
openssl rand -hex 24 | tr -d '\n' > /home/netbox/netbox/secrets/db_password
chmod 600 /home/netbox/netbox/secrets/*
umask 022

The first is NetBox's secret key, which signs logins and sessions. The second is the pepper NetBox mixes into API tokens before it stores their hashes: without it, the tokens you create in step 10 stop working, so step 15 saves a copy of both. The third is the database password. All three are kept as 0600 files in ./secrets/, not in the Compose file.

3. Define the Compose project

mkdir -p /home/netbox/netbox
chown -R netbox:netbox /home/netbox/netbox

Create /home/netbox/netbox/compose.yaml:

services:
  netbox-db:
    image: docker.io/library/postgres:18-alpine
    env_file:
      - ./netbox.env
    environment:
      POSTGRES_PASSWORD_FILE: /run/secrets/db_password
    secrets:
      - db_password
    volumes:
      - netbox-db:/var/lib/postgresql
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "netbox", "-d", "netbox"]
      interval: 10s
    restart: always

  netbox-valkey:
    image: docker.io/valkey/valkey:9.1-alpine
    command: valkey-server --appendonly yes
    volumes:
      - netbox-valkey:/data
    healthcheck:
      test: ["CMD", "valkey-cli", "ping"]
      interval: 10s
    restart: always

  netbox:
    image: docker.io/netboxcommunity/netbox:v4.7
    user: "netbox:root"
    env_file:
      - ./netbox.env
    secrets:
      - secret_key
      - db_password
      - api_token_pepper_1
    volumes:
      - netbox-media:/opt/netbox/netbox/media
      - netbox-scripts:/opt/netbox/netbox/scripts
    ports:
      - "127.0.0.1:8190:8080"
    healthcheck:
      test: ["CMD", "curl", "-sf", "http://localhost:8080/login/", "-o", "/dev/null"]
      interval: 15s
    depends_on:
      netbox-db:
        condition: service_healthy
      netbox-valkey:
        condition: service_healthy
    restart: always

  netbox-worker:
    image: docker.io/netboxcommunity/netbox:v4.7
    user: "netbox:root"
    command: /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker
    env_file:
      - ./netbox.env
    secrets:
      - secret_key
      - db_password
      - api_token_pepper_1
    volumes:
      - netbox-media:/opt/netbox/netbox/media
      - netbox-scripts:/opt/netbox/netbox/scripts
    depends_on:
      - netbox
    restart: always

volumes:
  netbox-db:
  netbox-valkey:
  netbox-media:
  netbox-scripts:

secrets:
  secret_key:
    file: ./secrets/secret_key
  db_password:
    file: ./secrets/db_password
  api_token_pepper_1:
    file: ./secrets/api_token_pepper_1

Both NetBox containers read the rest of their settings from one file. Create /home/netbox/netbox/netbox.env:

ALLOWED_HOSTS=netbox.example.com
TIME_ZONE=Europe/Stockholm
MEDIA_ROOT=/opt/netbox/netbox/media
DB_HOST=netbox-db
DB_NAME=netbox
DB_USER=netbox
REDIS_HOST=netbox-valkey
SKIP_SUPERUSER=true
ISOLATED_DEPLOYMENT=true

What the settings do:

  • Compose mounts each secret from ./secrets/ as a file under /run/secrets, named after its key.
  • ALLOWED_HOSTS is the name NetBox answers to; a request for any other name gets "400 Bad Request". The image adds localhost by itself, for its own checks and for the SSH tunnel in step 4.
  • TIME_ZONE shows times in Swedish time.
  • MEDIA_ROOT must be set: without it, the image looks for uploads in a directory NetBox cannot write to, and uploading an image fails with a permission error.
  • ISOLATED_DEPLOYMENT=true stops NetBox from contacting NetBox Labs. Step 13 has the details.
  • SKIP_SUPERUSER=true stops the image from creating an admin account with a default password. You create your own in step 4.
  • Every NetBox container is on the same Compose project, so they reach PostgreSQL and Valkey on 127.0.0.1, and nothing outside the Compose project can. Valkey keeps the task queue on disk with --appendonly yes, so queued webhooks survive a restart.
  • The web server runs as the netbox user inside the container, as netbox-docker intends. The netbox-media named volume holds uploaded images and files, and netbox-scripts named volume any custom scripts you upload. Everything else is in the database.
  • The worker runs the background jobs: webhooks, scripts, and NetBox's daily housekeeping, which removes expired sessions and old change log entries.
  • PostgreSQL stays on 18 and Valkey on 9.1, and the weekly update timer brings in their bug-fix releases. NetBox 4.7 needs PostgreSQL 15 or later.

Start it:

runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose up -d"

The first start downloads about 1 GB of images and then builds the database: the whole first start took ten minutes in our test. Follow it with journalctl --user -fu netbox. It is ready when the log says Initialisation is done and this prints 200:

curl -s -o /dev/null -w '%{http_code}\n' http://localhost:8190/login/

4. Create the first admin

runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -it netbox /opt/netbox/netbox/manage.py createsuperuser"

Give a username, such as anna, your email address and a password. NetBox wants at least 12 characters, with upper and lower case letters and a digit, and asks whether to bypass that if the password is weaker: answer N and pick another.

Before NetBox goes online, check the account from your own computer through an SSH tunnel:

ssh -L 8190:127.0.0.1:8190 root@203.0.113.10

While that connection is open, http://localhost:8190 in your browser is NetBox on the server. Log in, then close the tunnel with exit.

5. Put Caddy in front

Go back to root with exit, add this block at the end of /home/caddy/Caddyfile:

netbox.example.com {
    reverse_proxy 127.0.0.1:8190 {
        header_up X-Real-IP {remote_host}
    }
}

Restart Caddy with the command above, and open https://netbox.example.com.

NetBox takes the visitor's address from the X-Real-IP header first. Caddy does not set it by itself, so without the header_up line anyone could send their own and claim any address, which matters for API tokens limited to certain addresses (step 10). In our test, such a token accepted a forged header without the line, and refused it with the line in place.

6. Check who can get in

NetBox 4.7 always requires a login: a visitor without one is sent to the login page, and the API answers 403. Uploaded images need a login too. The old LOGIN_REQUIRED setting, which could turn that off, is deprecated, and NetBox 5.0 removes it; leave it out.

There is no sign-up page. You create every account yourself (step 9), and a user who forgets their password gets a new one from you: NetBox has no password reset by email. It only sends email for errors, to administrators listed in its ADMINS setting, which this guide leaves empty, so there is no email to set up.

NetBox can also leave logins to a single sign-on service, such as authentik, over OpenID Connect or SAML, or to LDAP. That is set with the REMOTE_AUTH_BACKEND and SOCIAL_AUTH_ settings in netbox-docker's documentation. We did not test it here.

7. Model a small server room

The menus on the left follow NetBox's own order: a site holds racks, a rack holds devices, devices have interfaces, and cables join interfaces. Everything you create shows up in the search at the top.

  1. Organization > Sites > Add: name Stockholm DC1, status Active, and the time zone. Create.
  2. Racks > Racks > Add: site Stockholm DC1, name R01. A 42U, 19-inch rack is the default. Create.
  3. Devices > Manufacturers > Add: name Generic. Create.

A device type describes a model of equipment once, with its height and its ports, so every device of that type gets them. Under Devices > Device Types, choose Import, paste this, set Format to YAML and choose Submit:

manufacturer: Generic
model: Switch 8
slug: generic-switch-8
u_height: 1
interfaces:
  - name: port1
    type: 1000base-t
  - name: port2
    type: 1000base-t
  - name: port3
    type: 1000base-t
  - name: port4
    type: 1000base-t
---
manufacturer: Generic
model: Server 1U
slug: generic-server-1u
u_height: 1
interfaces:
  - name: eth0
    type: 1000base-t
  - name: eth1
    type: 1000base-t

For real equipment, the community's device type library on GitHub, netbox-community/devicetype-library, has files like these for thousands of models, which you paste the same way.

Most lists have an Import button that takes CSV. Under Devices > Device Roles > Import, paste:

name,slug,color
Switch,switch,2196f3
Server,server,4caf50

And under Devices > Devices > Import:

name,role,manufacturer,device_type,site,rack,position,face,status
sw1,Switch,Generic,Switch 8,Stockholm DC1,R01,42,front,active
web1,Server,Generic,Server 1U,Stockholm DC1,R01,40,front,active
db1,Server,Generic,Server 1U,Stockholm DC1,R01,39,front,active

The rack's page now draws the three devices at their heights, and each device has the interfaces of its type. An import either creates every row or none: if one row is wrong, NetBox shows the error and nothing is saved. Each import page lists the columns it accepts below the form.

To connect a cable, open sw1, go to its Interfaces tab, and on the row for port1 open the green Connect cable button and choose Interface. Pick device web1 and interface eth0, give the cable a label such as C001 and a type, and choose Create. The second cable comes by CSV, under Connections > Cables > Import:

side_a_device,side_a_type,side_a_name,side_b_device,side_b_type,side_b_name,type,status,label
sw1,dcim.interface,port2,db1,dcim.interface,eth0,cat6,connected,C002

Each interface now shows what it is connected to, at the other end of which cable.

To attach a photo of the rack, open it and choose Attach an image. Images go in the netbox-media named volume.

8. IP addresses and VLANs

  1. IPAM > VLANs > Add: VID 10, name Servers, status Active, site Stockholm DC1. Create.
  2. IPAM > Prefixes > Add: prefix 10.10.10.0/24, status Active, Scope DCIM > Site and Stockholm DC1, VLAN Servers, a description such as Server LAN. Create.

The prefix's page shows how much of it is used, and under First available IP the next free address, 10.10.10.1/24. Selecting it opens a new IP address with that address filled in: give it the description Gateway and choose Create. The IP Addresses tab on the prefix lists the used addresses with the free ranges between them.

To give a server its address, add another IP address from the same link, and under Assignment pick device web1 and interface eth0, and tick Make this the primary IP for the device/VM. The device's page then shows it as its primary IPv4 address.

9. Users, groups and permissions

A user who is not a superuser can do nothing until a permission allows it. Permissions are given to groups, so give the colleague a group. Under Admin > Authentication:

  1. Groups > Add: name Read-only. Create.
  2. Permissions > Add: name View inventory. Under Object types, select every type in the Circuits, DCIM, IPAM, Tenancy, Virtualization, VPN and Wireless groups in the Available list (hold Shift to select several) and move them to Selected with the green button. Under Actions, tick Can view only, and under Assignment, pick the group Read-only. Create.
  3. Users > Add: username erik, a password, and the group Read-only. Create.

Erik can now open every device, rack, cable and address, but gets "403 Forbidden" when he tries to add or change anything, and cannot see users or permissions. The Core, Extras and Users groups are left out on purpose: they hold jobs, scripts, webhooks, users and tokens. A permission can also be limited to certain objects with Constraints, such as one site only. We did not test that.

Each user can choose one of its 17 languages, or the theme, under Preferences in the user menu at the top right.

10. Use the REST API

Scripts and other tools read and write NetBox through its REST API, with a token. In the user menu, choose API Tokens > Add a Token, keep Version at v2, tick Write enabled if the token should be able to change things, and choose Create. NetBox shows the token once, starting with nbt_; copy it then.

From any computer, with your token in place of nbt_…:

TOKEN='nbt_…'
curl -s -H "Authorization: Bearer $TOKEN" "https://netbox.example.com/api/ipam/prefixes/?prefix=10.10.10.0/24"

The answer has the prefix's id, here 1. Ask for its next free address:

curl -s -H "Authorization: Bearer $TOKEN" "https://netbox.example.com/api/ipam/prefixes/1/available-ips/?limit=1"

Or take it in the same call, so two scripts never get the same one:

curl -s -X POST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"description": "mail1", "dns_name": "mail1.example.com"}' \
  https://netbox.example.com/api/ipam/prefixes/1/available-ips/

NetBox answers with the new address, in our test 10.10.10.3/24, now saved as active. https://netbox.example.com/api/schema/swagger-ui/ describes every call. A token can be limited to certain addresses in its Allowed IPs field, and given an expiry date. It has the same rights as its user, so give a script a user of its own with only the permissions it needs.

11. Webhooks and event rules

An event rule makes NetBox act when something changes, for example call a webhook, another system's address, when an IP address is created. To see what NetBox sends, start its test receiver as netbox, in a second SSH session:

runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -it netbox /opt/netbox/netbox/manage.py webhook_receiver"

It listens on port 9000 inside the Compose project. Then, under Operations > Integrations:

  1. Webhooks > Add: name Test receiver, URL http://127.0.0.1:9000/, method POST, and as Body template:
    {"text": "IP address {{ data.address }} was {{ event }} by {{ request.user }}"}
    

    Create.
  2. Event Rules > Add: name New IP addresses, object type IPAM > IP Address, event Object created, action type Webhook, webhook Test receiver. Create.

Create an IP address, by hand or with the API call above, and the receiver prints the request a second later, with "text": "IP address 10.10.10.4/24 was created by anna". Stop it with Ctrl+C. Use 127.0.0.1 rather than localhost in the URL: localhost is the IPv6 address in the container, where the receiver does not listen.

For real use, point the webhook at a service that takes it, such as a topic on ntfy or an automation in n8n. If that service runs on this server, add add ntfy.example.com:host-gatewayunderextra_hosts:incompose.yaml`` under [Pod] in netbox.Compose project, as the Docker guide explains. The worker sends the webhooks, and failed ones are listed under Admin > System > Background Tasks, where you can send them again. Only let people you trust create webhooks: their templates run on the server.

12. The change log

Every change, in the web interface, by import or through the API, is recorded with who made it, when, and what the object looked like before and after. Operations > Logging > Change Log lists them all, and each object has a Changelog tab of its own. An import or a bulk edit shares one request ID, so you can see everything it changed together.

NetBox keeps changes for 90 days. To keep them longer, add CHANGELOG_RETENTION=365 to /home/netbox/netbox/netbox.env, or 0 to keep them forever, and restart as below.

runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose restart netbox netbox-worker"

13. Outside connections

We captured the server's DNS lookups and outgoing connections while NetBox started, while its pages were used and while its daily housekeeping ran. Without ISOLATED_DEPLOYMENT=true, NetBox made three kinds:

  • The daily housekeeping job sent census data to census.netbox.oss.netboxlabs.com: the NetBox version, the Python version and a random ID, so NetBox Labs can count installations. CENSUS_REPORTING_ENABLED=false stops only that.
  • The NetBox News panel on the home page made the server fetch news from api.netbox.oss.netboxlabs.com every four hours.
  • Admin > System > Plugins made the server fetch NetBox Labs' list of plugins from the same address.

Two more are off unless you turn them on. NetBox Copilot, NetBox Labs' AI assistant, is off for every user until they switch it on under Preferences; then their browser loads it from static.copilot.netboxlabs.ai, and what they ask it goes to NetBox Labs. The check for new NetBox releases is off in this image, and turned on with RELEASE_CHECK_URL=https://api.github.com/repos/netbox-community/netbox/releases, which makes the server ask GitHub.

ISOLATED_DEPLOYMENT=true turns all of these off, and with it our capture showed no outside connections at all. The NetBox News panel then says "This RSS feed requires an external connection"; remove it from your home page with its ✕. It also hides the links to NetBox Labs' cloud and enterprise offers in the menu. Webhooks still go out, to the addresses you give them.

14. Add a plugin

Plugins add features to NetBox, and must be installed into the image. As netbox, make a directory for a small image of your own:

mkdir -p ~/netbox-plugins
cd ~/netbox-plugins

Create Containerfile, here with the Topology Views plugin, which draws your devices and cables as a map:

FROM docker.io/netboxcommunity/netbox:v4.7
RUN uv pip install netbox-topology-views==4.7.0
COPY plugins.py /etc/netbox/config/plugins.py
RUN mkdir -p /opt/netbox/netbox/static/netbox_topology_views/img && \
    DEBUG=true SECRET_KEY=only-used-while-building-only-used-while-building-xx \
    python /opt/netbox/netbox/manage.py collectstatic --no-input

And plugins.py:

PLUGINS = ["netbox_topology_views"]

Build it:

docker build --pull -t netbox-plugins:v4.7 .

The SECRET_KEY there is only used to collect the plugin's files while building, and is not your real key. Then, in compose.yaml, change the image: line of both netbox and netbox-worker to netbox-plugins:v4.7:

image: netbox-plugins:v4.7

And restart:

runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose restart netbox netbox-worker"

NetBox creates the plugin's tables when it starts, and it shows under Admin > System > Plugins. Under Topology Views > Topology, pick the site, tick Show Cables and choose Search to see the switch with the two servers.

Each plugin release works with certain NetBox versions only, which its page lists. Pin the version, as above, and check that a new one exists before you move to a new NetBox version (step 16).

15. Back up

As netbox:

umask 077
mkdir -p /home/netbox/backup
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec netbox-db pg_dump -U netbox netbox" > /home/netbox/backup/netbox-db.sql
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -T netbox tar -C /opt/netbox/netbox/media -czf - ." > /home/netbox/backup/netbox-media.tar
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -T netbox tar -C /opt/netbox/netbox/scripts -czf - ." > /home/netbox/backup/netbox-scripts.tar
cp /home/netbox/netbox/secrets/secret_key /home/netbox/backup/secret_key.txt
cp /home/netbox/netbox/secrets/api_token_pepper_1 /home/netbox/backup/api_token_pepper.txt

That is everything NetBox needs: the database, with all objects, users, permissions, tokens and the change log, the uploaded images and scripts, and the two secrets. The API tokens only work with the pepper they were made with. The dump runs while NetBox keeps working. Valkey holds only the cache and the task queue, which NetBox rebuilds. Copy /home/netbox/backup to another machine, for example with restic, and store it safely: the database holds your whole network map.

To restore on a new server, follow steps 1 to 3, but create the first two secrets from the backup instead of new ones, and do not start the Compose project yet:

cp /home/netbox/backup/secret_key.txt /home/netbox/netbox/secrets/secret_key
cp /home/netbox/backup/api_token_pepper.txt /home/netbox/netbox/secrets/api_token_pepper_1
openssl rand -hex 24 | tr -d '\n' > /home/netbox/netbox/secrets/db_password
chmod 600 /home/netbox/netbox/secrets/*

If you used a plugin, build the same image as in step 14. Then load the backup into empty volumes:

docker compose up -d netbox-db
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -i netbox-db psql -q -o /dev/null -U netbox -d netbox" < /home/netbox/backup/netbox-db.sql
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -T netbox tar -C /opt/netbox/netbox/media -xzf - < /home/netbox/backup/netbox-media.tar"
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose exec -T netbox tar -C /opt/netbox/netbox/scripts -xzf - < /home/netbox/backup/netbox-scripts.tar"
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose up -d"

Starting only the database first loads the backup before NetBox sets up an empty one. Skip step 4: your accounts are in the backup. To restore on the same server, stop the project with docker compose down and remove the old volumes with docker compose down -v.

16. Update

The weekly docker-update.service and docker-update.timer from the rootless Docker guide pull new images of NetBox, PostgreSQL and Valkey and recreate the Compose project, with WorkingDirectory=/home/netbox/netbox. The v4.7 tag gets every NetBox 4.7 bug-fix release. To update now:

A new minor version, such as 4.8, changes the database and can drop old settings, so it is a step you take yourself:

  1. Read the release notes on GitHub, netbox-community/netbox, for the breaking changes.
  2. Take a backup as in step 15.
  3. Change v4.7 to the new version in the image: lines of netbox and netbox-worker, or in the Containerfile if you use plugins, with plugin versions that support it, and build again.
  4. Restart:
runuser -u netbox -- env HOME=/home/netbox XDG_RUNTIME_DIR=/run/user/$uid \
  DOCKER_HOST=unix:///run/user/$uid/docker.sock PATH=/usr/bin:/bin \
  bash -lc "cd /home/netbox/netbox && docker compose restart netbox netbox-worker"

NetBox runs its database migrations when it starts. From 4.6.10 to 4.7.3 that took three minutes in our test, during which the web interface was down; follow it with journalctl --user -fu netbox. Within NetBox 4 you can skip minor versions; NetBox 5.0 will need the last 4.x release first. Let the background jobs finish first: the 4.7 release notes warn that queued webhooks from the old version fail after the update.

With plugins, the weekly timer does not fetch new NetBox images from the registry. Build the image again with the command from step 14 to get the latest 4.7 release, then run docker compose up -d to recreate the services on the new image.

Troubleshooting

NetBox does not answer for several minutes after the first start or an update. It is building or migrating its database, and docker compose ps shows activating until it is done. journalctl --user -fu netbox shows each migration. Give it time: in the Podman test the first start took ten minutes.

"Bad Request (400)". The name in the address bar is not in ALLOWED_HOSTS. Fix /home/netbox/netbox/netbox.env and restart.

Uploading an image fails with "A file permission error was detected" and /etc/netbox/media. MEDIA_ROOT is missing from /home/netbox/netbox/netbox.env.

The log keeps warning that "LOGIN_REQUIRED is deprecated". netbox-docker's own configuration still sets it, and NetBox warns on every start. It is harmless, and logins are still required.

"Password must have at least one uppercase letter." NetBox's password rules apply to every account: 12 characters or more, with upper and lower case letters and a digit.

A webhook fails with "Connection refused". The receiving address does not answer from inside the Compose project. A service on this server needs the AddHost= line from step 11, and localhost means IPv6 there.

Run it on your own server

SSD RAID 1 · ECC DDR4 · 10 Gbit

VC-P Alloy

€8.99/mo

vCPU
2
Memory
8 GB
Storage
60 GB
Transfer
10 TB
Performance
SSD · RAID 1
  • Full root access
  • Native /64 IPv6
  • RAID-protected storage
  • Malmö, Sweden
  • Month to month, no lock-in
  • 7-day money-back guarantee

These steps were tested on VC-P Titanium. This uses so little that VC-P Alloy, with the same number of vCPUs and memory on an older CPU, is enough at a small scale and costs less.

All guides