2023-01-23 14:23:54 +05:00
# Netbox Docker
2023-01-23 14:16:27 +05:00
2023-01-23 14:23:54 +05:00
## Setup the service:
- Install docker or podman
- Save the following content as `docker-compose.yml`
2023-01-23 14:16:27 +05:00
```yaml
version: '3.5'
services:
################################################
netbox:
image: git.shihaam.dev/dockerfiles/netbox
ports:
- 8000:8000
volumes:
- ./configuration.py:/opt/netbox/netbox/netbox/configuration.py
2023-01-23 14:27:09 +05:00
command: python manage.py runserver 0.0.0.0:8000 --insecure # COMMENT THIS LINE AND REVERSE PROXYIN PRODUCTION !!!
2023-01-23 14:16:27 +05:00
depends_on:
- redis
- postgres
2023-01-23 14:35:22 +05:00
restart: always
2023-01-23 14:16:27 +05:00
################################################
postgres:
image: postgres:13-alpine
volumes:
- ./data/db:/var/lib/postgresql/data
environment:
- POSTGRES_DB=netbox
- POSTGRES_USER=netbox
2023-01-25 08:58:01 +05:00
- POSTGRES_PASSWORD=netbox # CHANGE THIS IN PRODUCTION !!
2023-01-23 14:16:27 +05:00
restart: always
################################################
redis:
image: redis:6.0-alpine
restart: always
```
2023-01-25 07:58:53 +05:00
- Fetch example config from container `docker compose run --rm netbox cat /opt/netbox/netbox/netbox/configuration_example.py > configuration.py` and edit it according to your enviroment.
2023-01-24 09:04:27 +05:00
- Create `devicetype-images` and `image-attachments` folders under media folder
```bash
mkdir -p media/image-attachments media/devicetype-images
```
2023-01-25 07:59:58 +05:00
- Generate Secret key `docker compose run --rm netbox ./generate_secret_key.py` , add output of this to configuration.py
2023-01-23 14:23:54 +05:00
- Run `docker compose up -d`
2023-01-23 14:16:27 +05:00
2023-01-23 14:27:09 +05:00
## PLEASE, FOR THE LOVE OF GOD PLEASE DO NOT USE PASSWORD I GAVE IN THIS REPO IN PRODUCTION !!
2023-01-23 14:16:27 +05:00
## Some commands that will be useful
- Migrate Database (required on initial install and upgrade
```bash
docker compose exec netbox ./manage.py migrate
```
- Create new Superuser account, (it might not show any output, just enter a username and press enter)
```bash
docker compose exec netbox ./manage.py createsuperuser
```