본문 바로가기

리눅스

우분투 24.04에서 Docker Compose를 사용하여 NetBox를 설치하는 방법

반응형

우분투 24.04에서 Docker Compose를 사용하여 NetBox를 설치하는 방법

1. 필수 패키지 및 Docker 설치

Docker와 Git을 설치합니다.

sudo apt update
sudo apt install -y git

2. NetBox Docker 레포지토리 복제

공식적으로 관리되는 netbox-docker 저장소를 가져옵니다.

git clone -b release https://github.com/netbox-community/netbox-docker.git
cd netbox-docker

3. 환경 설정 (Configuration)

예제 설정 파일을 복사하여 활성화합니다.

# 설정 파일 생성
cp docker-compose.override.yml.example docker-compose.override.yml

그 후, env/netbox.env 파일을 열어 SECRET_KEY를 생성하여 넣어야 합니다. (최소 50자 이상의 랜덤 문자열)

# 랜덤 키 생성 (복사해서 netbox.env의 SECRET_KEY 부분에 넣으세요)
NEW_KEY=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 50 ; echo)
sed -i "s|^SECRET_KEY=.*|SECRET_KEY=${NEW_KEY}|" env/netbox.env

변경 확인

grep "SECRET_KEY" env/netbox.env
728x90

4. 컨테이너 실행

이제 모든 서비스를 백그라운드에서 실행합니다.

처음 실행 시 이미지를 내려받고 DB를 초기화하느라 시간이 약간(2~3분) 소요됩니다.

sudo docker compose up -d

netbox 컨테이너 로그 확인

sudo docker compose logs -f netbox
...
netbox-1  |   wireless.wirelesslan... No objects found.
netbox-1  |   wireless.wirelesslangroup... No objects found.
netbox-1  |   wireless.wirelesslink... No objects found.
netbox-1  | Completed. Total entries: 7
netbox-1  | ↩️ Skip creating the superuser
netbox-1  | ✅ Initialisation is done.
netbox-1  | [INFO] Starting granian (main PID: 8)
netbox-1  | [INFO] Listening at: http://:::8080
netbox-1  | [INFO] Spawning worker-1 with PID: 413
netbox-1  | [INFO] Spawning worker-2 with PID: 415
netbox-1  | [INFO] Spawning worker-3 with PID: 417
netbox-1  | [INFO] Spawning worker-4 with PID: 419
  • 모든 컨테이너 중지 및 삭제
sudo docker compose down -v

5. 관리자(Superuser) 계정 생성

웹 화면에 로그인하기 위해 관리자 계정을 만들어야 합니다.

sudo docker compose exec netbox /opt/netbox/netbox/manage.py createsuperuser
 loaded config '/etc/netbox/config/configuration.py'
 loaded config '/etc/netbox/config/extra.py'
 loaded config '/etc/netbox/config/logging.py'
 loaded config '/etc/netbox/config/plugins.py'
Username: admin
Email address: admin@scbyun.com
Password: 
Password (again): 
This password is too short. It must contain at least 12 characters.
Password must have at least one numeral.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

사용자 이름, 이메일, 비밀번호를 순서대로 입력하세요.

웹 UI 접속

브라우저를 열고 아래 주소로 접속합니다.

http://[서버_IP_주소]:8000

 

728x90
반응형