# Netbox Docker ## Setup the service: - Install docker or podman - Save the following content as `docker-compose.yml` ```yaml version: '3.5' services: ################################################ netbox: image: git.shihaam.dev/dockerfiles/netbox ports: - 8000:8000 volumes: - ./configuration.py:/opt/netbox/netbox/netbox/configuration.py command: python manage.py runserver 0.0.0.0:8000 --insecure # COMMENT THIS LINE AND REVERSE PROXYIN PRODUCTION !!! depends_on: - redis - postgres restart: always ################################################ postgres: image: postgres:13-alpine volumes: - ./data/db:/var/lib/postgresql/data environment: - POSTGRES_DB=netbox - POSTGRES_USER=netbox - POSTGRES_PASSWORD=even-confider-closable # CHANGE THIS IN PRODUCTION !! restart: always ################################################ redis: image: redis:6.0-alpine restart: always ``` - 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. - Create `devicetype-images` and `image-attachments` folders under media folder ```bash mkdir -p media/image-attachments media/devicetype-images ``` - Generate Secret key `docker compose run --rm netbox ./generate_secret_key.py`, add output of this to configuration.py - Run `docker compose up -d` ## PLEASE, FOR THE LOVE OF GOD PLEASE DO NOT USE PASSWORD I GAVE IN THIS REPO IN PRODUCTION !! ## 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 ```