Welcome to this guide to learn how to run the Netbox IPAM tool in a Docker container. But before we delve into the core of this problem, let us first understand the entire content of the Netbox IPAM tool.
Netbox is a free and open source tool for managing and recording computer networks via the Web. Netbox IPAM is written in Django. It helps to simplify the task of creating a virtual realization of equipment in the data center, which was originally completed on paper. The amazing features of Netbox IPAM include:
- VLAN management
- Virtual reality management
- IPAM-IP address management
- DCIM-Data Center Infrastructure Management
- Circuit supplier management
- Multi-site (rental)
- Single converged database
- Rack height
- Report alert
- Connection Management-Interface/Console/Power
- Custom titles for logos, etc.
Running Netbox with Docker Containers is easy because it avoids all the tedious tasks of installing dependencies such as Python and Django.
Before we start this guide, please make sure that your system is up to date and has the required software packages installed.
## On Debian/Ubuntu sudo apt update && sudo apt upgrade sudo apt install curl vim git ## On RHEL/CentOS/RockyLinux 8 sudo yum -y update sudo yum -y install curl vim git ## On Fedora sudo dnf update sudo dnf -y install curl vim git
1. Install Docker and Docker-Compose on Linux
This setting relies on Docker and docker-compose that meet the following requirements:
- Docker version 19.03 above
- docker-compose version 1.28.0 above
Use the following guide to install the latest version of Docker CE on Linux.
- How to install Docker CE on Linux system
Verify the installed Docker version.
$ docker -v Docker version 20.10.10, build b485636
Then add your system user to the docker group so that when not in use sudo Order.
sudo usermod -aG docker $USER newgrp docker
Now go ahead and install Docker-compose on Linux. Download the latest version of docker-compose as follows.
curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url | grep docker-compose-linux-x86_64 | cut -d '"' -f 4 | wget -qi -
Make the file executable.
chmod +x docker-compose-linux-x86_64
Move the file to your PATH.
sudo mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
Verify your installation by checking the docker-compose version.
$ docker-compose version Docker Compose version v2.1.1
Now start and enable docker.
sudo systemctl start docker && sudo systemctl enable docker
2. Configure Netbox IPAM server
All the components needed to build Netbox as a docker container are available in the Github repository.Here, the image is constructed and posted to Docker Center with Quay.io once a day.
Now the git clone Netbox docker file is as follows.
git clone -b release https://github.com/netbox-community/netbox-docker.git
Navigate to the Netbox directory.
Revise docker-compose.yml From docker-compose.override.yml.example The file is as follows.
tee docker-compose.override.yml <<EOF version: '3.4' services: netbox: ports: - 8000:8080 EOF
Now we are ready to start our docker container.But first, pull the required images for Netbox, PostgreSQL, Redis, etc.
$ docker-compose pull
A few pictures will be pulled as follows
........... ⠿ postgres Pulled 13.5s ⠿ 9f97b97dbe44 Pull complete 3.5s ⠿ 1b95022c44c5 Pull complete 3.7s ⠿ 560a1e367f24 Pull complete 8.0s ⠿ 41255ef20c58 Pull complete 8.3s ⠿ 13107d5a09d7 Pull complete 8.6s ⠿ 234db58e5916 Pull complete 8.8s ⠿ 98ce0f30aef7 Pull complete 9.1s ⠿ redis Pulled 9.3s ⠿ 97518928ae5f Already exists 0.8s ⠿ 66f8c4150d27 Pull complete 2.5s ⠿ redis-cache Pulled 9.3s ⠿ 09a8bf17a0bf Pull complete 3.1s ⠿ e547313af8e7 Pull complete 4.0s ⠿ 335eeadfbde0 Pull complete 4.6s ⠿ 7151fc2c01eb Pull complete
Start the Netbox IPAM container.
$ docker-compose up
[+] Running 10/10 ⠿ Network netbox-docker_default Created 0.2s ⠿ Volume "netbox-docker_netbox-media-files" Created 0.0s ⠿ Volume "netbox-docker_netbox-postgres-data" Created 0.0s ⠿ Volume "netbox-docker_netbox-redis-data" Created 0.0s ⠿ Container netbox-docker-redis-cache-1 Created 0.7s ⠿ Container netbox-docker-postgres-1 Created 0.6s ⠿ Container netbox-docker-redis-1 Created 0.7s ⠿ Container netbox-docker-netbox-worker-1 Created 0.5s ⠿ Container netbox-docker-netbox-housekeeping-1 Created 0.5s ⠿ Container netbox-docker-netbox-1 Created 0.3s Attaching to netbox-docker-netbox-1, netbox-docker-netbox-housekeeping-1, netbox-docker-netbox-worker-1, netbox-docker-postgres-1, netbox-docker-redis-1, netbox-docker-redis-cache-1 .................... netbox-docker-netbox-1 | ⏳ Waiting for control socket to be created... (1/10) netbox-docker-netbox-1 | 2021/11/15 10:37:29 [warn] 7#7 Unit is running unprivileged, then it cannot use arbitrary user and group. netbox-docker-netbox-1 | 2021/11/15 10:37:29 [info] 7#7 unit started netbox-docker-netbox-1 | 2021/11/15 10:37:29 [info] 20#20 discovery started netbox-docker-netbox-1 | 2021/11/15 10:37:29 [notice] 20#20 module: python 3.9.5 "/usr/lib/unit/modules/python3.unit.so" netbox-docker-netbox-1 | 2021/11/15 10:37:29 [info] 7#7 controller started netbox-docker-netbox-1 | 2021/11/15 10:37:29 [notice] 7#7 process 20 exited with code 0 netbox-docker-netbox-1 | 2021/11/15 10:37:29 [info] 22#22 router started netbox-docker-netbox-1 | 2021/11/15 10:37:29 [info] 22#22 OpenSSL 1.1.1l 24 Aug 2021, 101010cf netbox-docker-netbox-1 | ⚙️ Applying configuration from /etc/unit/nginx-unit.json netbox-docker-netbox-1 | 2021/11/15 10:37:30 [info] 26#26 "netbox" application started netbox-docker-netbox-1 | ✅ Unit configuration loaded successfully netbox-docker-netbox-1 | 2021/11/15 10:37:31 [notice] 7#7 process 18 exited with code 0
When you see the above output, the process is complete, now exit, continue and verify that the container is running:
$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ead31a95654a netboxcommunity/netbox:v3.0-1.4.1 "/sbin/tini -- /opt/…" 2 minutes ago Up 2 minutes 0.0.0.0:8000->8080/tcp, :::8000->8080/tcp netbox-docker-netbox-1 d652988275e6 netboxcommunity/netbox:v3.0-1.4.1 "/sbin/tini -- /opt/…" 2 minutes ago Up 2 minutes netbox-docker-netbox-housekeeping-1 6ee0e21ecde0 netboxcommunity/netbox:v3.0-1.4.1 "/sbin/tini -- /opt/…" 2 minutes ago Up 2 minutes netbox-docker-netbox-worker-1 3ff7e0c6b174 redis:6-alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp netbox-docker-redis-cache-1 92e49f207764 redis:6-alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 6379/tcp netbox-docker-redis-1 77908ccce0ca postgres:13-alpine "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 5432/tcp netbox-docker-postgres-1
If you have a firewall enabled, please allow port 8000 as shown below.
##For Firewalld sudo firewall-cmd --zone=public --add-port=8000/tcp --permanent sudo firewall-cmd --reload ##For UFW sudo ufw allow 8000/tcp
3. Access the Netbox IPAM tool Web UI
Use the default credentials as the username to log in to the page: admin, password: admin, with API token: 0123456789abcdef0123456789abcdef01234567
After successfully logging in, you will see this page.
Now you can use the panel on the left to navigate as shown.
On this panel, you can add devices, connections, circuits, IPAM, clusters, power supplies, and many other items to be managed.
This provides an implementation, that is, using Netbox IPAM tools, it is very easy to manage the data center by adding the required equipment.
To add a device, such as a router, you will add the following information.
If you want to stop all running containers, run the following command:
$ docker-compose stop
You can delete the container as shown below.
$ docker-compose stop && docker-compose rm
+] Running 6/0 ⠿ Container netbox-docker-netbox-housekeeping-1 Stopped 0.0s ⠿ Container netbox-docker-netbox-1 Stopped 0.0s ⠿ Container netbox-docker-netbox-worker-1 Stopped 0.0s ⠿ Container netbox-docker-redis-cache-1 Stopped 0.0s ⠿ Container netbox-docker-redis-1 Stopped 0.0s ⠿ Container netbox-docker-postgres-1 Stopped 0.0s ? Going to remove netbox-docker-netbox-1, netbox-docker-netbox-housekeeping-1, netbox-docker-netbox-worker-1, netbox-docker-redis-cache-1, netbox-docker-redis-1, netbox-docker-postgres-1 (y/N) y
now it’s right! At this point, we all agree that it is easier to run the Netbox IPAM tool in a Docker container. I hope you successfully set up the Netbox IPAM tool Docker container.
See more guides:
- Install NetBox IPAM and DCIM tools on Ubuntu
- How to install NetBox IPAM on Debian Linux
- How to install NetBox on Ubuntu 18.04 LTS
- Install NetBox IPAM on Rocky Linux 8|CentOS 8