Manage Docker with Netbox & style.
Project description
Netbox Docker Plugin
Manage Docker with Netbox & style. Made to work with netbox-docker-agent.
Thanks dzove855 for the presentation of the plugin the 15th April 2025 during the Netbox Community Call.
How does it work?
sequenceDiagram
Netbox->>Agent: Change (Webhook)
Agent->>Docker API: Request (HTTP)
Docker API->>Agent: Response (HTTP)
Agent->>Netbox: Feedback (Callback)
Once the plugin and webhooks are installed, you can:
- Create hosts that point to agents you had installed *
- Retrieve informations from Docker API with the help of the agent
- Create containers on host with an image, expose ports, add env variables and labels, mount volumes, set networks.
- Manage the container status, start, stop, restart.
[!NOTE]
Adding a host with curl needs a specificOriginHTTP header to make it working. Example :curl \ -H "Authorization: Token YOUR-NETBOX-APIKEY" \ -H "Content-Type: application/json" \ -H "Origin: https://YOUR-NETBOX-HOST" \ -X POST https://YOUR-NETBOX-HOST/api/plugins/docker/hosts/ \ -d '{"name": "YOUR-AGENT-NAME", "endpoint": "https://AGENT-USER:PASSWORD@YOUR-AGENT-HOST:PORT"}'
Installation
Below the compatibility list of the Netbox Docker PLugin and Netbox. Please chose the right version of the plugin depending of the Netbox version you use:
| Netbox Version | Netbox Docker Plugin Version |
|---|---|
| 3.* | 1.* |
| 4.0.* | 2.* |
| 4.1.* | 3.* |
| 4.2.* | 4.* |
| 4.3.* | 4.* |
| >=4.3.7 | >=4.5.1 |
You can follow the official plugins installation instructions.
If needed, source your Netbox's virtual environment and install the plugin like
a package. We assume you have already installed
Netbox and its source code are
in /opt/netbox:
cd /opt/netbox
python3 -m venv venv # if virtual env was not created before
source /opt/netbox/venv/bin/activate
pip install netbox-docker-plugin
Enable the plugin in the /opt/netbox/netbox/netbox/configuration.py file:
PLUGINS = [
'netbox_docker_plugin',
]
Then, run migrations:
cd /opt/netbox
python3 netbox/manage.py migrate
[!IMPORTANT] In order to the communication between your Netbox instance and the Agent works, the plugin will check if webhooks to agents are presents on each migration phase. If not, then the plugin will automatically install webhooks configuration in your Netbox instance.
Alternative
Another way to install Netbox is to use the Official netbox-docker project.
With this alternate way, you can customize your Netbox image and migrations will be automatically execute each time you restart the container.
Contribute
Install our development environment
Requirements:
- Python 3.11
- PostgreSQL 15 Official Netbox doc
- user: netbox (with database creation right)
- password: secret
- database: netbox
- port: 5432
- Redis 7.2
- port: 6379
Set a PROJECT variable :
PROJECT="/project/netbox"
Create a project directory $PROJECT:
mkdir $PROJECT
Go inside your project directory, clone this repository and the Netbox repository:
cd $PROJECT
git clone git@github.com:SaaShup/netbox-docker-plugin.git
git clone git@github.com:netbox-community/netbox.git
Create your venv and activate it:
python -m venv venv
source venv/bin/activate
Install netbox-docker-plugin dependencies:
cd $PROJECT/netbox-docker-plugin
pip install -e .
Configure Netbox and install Netbox dependencies:
cd $PROJECT/netbox
cp $PROJECT/netbox-docker-plugin/netbox_configuration/configuration_dev.py $PROJECT/netbox/netbox/netbox/configuration.py
pip install -r requirements.txt
Run database migrations:
cd $PROJECT/netbox
python3 netbox/manage.py migrate
Create a Netbox super user:
cd $PROJECT/netbox
python3 netbox/manage.py createsuperuser
Start Netbox instance:
cd $PROJECT/netbox
python3 netbox/manage.py runserver 0.0.0.0:8000 --insecure
Visit http://localhost:8000/
Run tests
After installing your development environment, you can run the tests plugin (you don't need to start the Netbox instance):
cd $PROJECT/netbox
python3 -m pip install requests_mock
python3 netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2
With code coverage, install coverage.py and use it:
cd $PROJECT/netbox
python3 -m pip install coverage
Then run the test with coverage.py and print the report:
cd $PROJECT/netbox
coverage run --include='*/netbox_docker_plugin/*' netbox/manage.py test netbox_docker_plugin.tests --keepdb -v 2
coverage report -m
Hosting
Check https://saashup.com for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file netbox_docker_plugin-4.11.0.tar.gz.
File metadata
- Download URL: netbox_docker_plugin-4.11.0.tar.gz
- Upload date:
- Size: 52.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c1244c7df100a25c810ffb23fd077ccf6cdba453d75ce0ff53eeb57aaae1a0e
|
|
| MD5 |
5d60ca0e9fcbd1c5085024a81281d0ef
|
|
| BLAKE2b-256 |
48283fa463a93a2df035d78dc73b7001f2807a1aa15fd7c515be914216879671
|
Provenance
The following attestation bundles were made for netbox_docker_plugin-4.11.0.tar.gz:
Publisher:
tags_cd.yml on SaaShup/netbox-docker-plugin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
netbox_docker_plugin-4.11.0.tar.gz -
Subject digest:
8c1244c7df100a25c810ffb23fd077ccf6cdba453d75ce0ff53eeb57aaae1a0e - Sigstore transparency entry: 801155311
- Sigstore integration time:
-
Permalink:
SaaShup/netbox-docker-plugin@6bd8d296c6fcc213a0ef1ef3d78276abf4a4f6a9 -
Branch / Tag:
refs/tags/v4.11.0 - Owner: https://github.com/SaaShup
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tags_cd.yml@6bd8d296c6fcc213a0ef1ef3d78276abf4a4f6a9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file netbox_docker_plugin-4.11.0-py3-none-any.whl.
File metadata
- Download URL: netbox_docker_plugin-4.11.0-py3-none-any.whl
- Upload date:
- Size: 108.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69587e4c2dfe8350995e89a6b90eb8757a2b6d9403bdbeec5054982071abcbbf
|
|
| MD5 |
8f7c6d1a89466f9a0953a521e821c3ad
|
|
| BLAKE2b-256 |
e1f742e47b9066ff52e2e0f75a1189d119c88ccaef03e94327c3fc0917da9884
|
Provenance
The following attestation bundles were made for netbox_docker_plugin-4.11.0-py3-none-any.whl:
Publisher:
tags_cd.yml on SaaShup/netbox-docker-plugin
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
netbox_docker_plugin-4.11.0-py3-none-any.whl -
Subject digest:
69587e4c2dfe8350995e89a6b90eb8757a2b6d9403bdbeec5054982071abcbbf - Sigstore transparency entry: 801155369
- Sigstore integration time:
-
Permalink:
SaaShup/netbox-docker-plugin@6bd8d296c6fcc213a0ef1ef3d78276abf4a4f6a9 -
Branch / Tag:
refs/tags/v4.11.0 - Owner: https://github.com/SaaShup
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tags_cd.yml@6bd8d296c6fcc213a0ef1ef3d78276abf4a4f6a9 -
Trigger Event:
push
-
Statement type: