# NetMonitor — Docker Image Build & Deploy Guide Clean, reproducible image: **Ubuntu 26.04 + sshd + Python 3 + NetMonitor (empty database)**. No collected data, no hosts — first boot auto-creates the admin account. | Item | Value | |---|---| | Web UI | `http://:7080` | | SSH | `root@` port **7022** (password = build arg) | | First login | `sysadmin` / `pas4admin` (change it after first login) | | App home | `/opt/netmonitor` (logs: `/var/log/netmonitor.log`) | | Service control | `/etc/init.d/netmonitor {start|stop|restart|status}` | ## 1. Build the image From the project root (folder containing `Dockerfile`): ```bash docker build --build-arg ROOT_PASSWORD='ChangeMe-RootPass' -t netmonitor:latest . ``` - `ROOT_PASSWORD` sets the container's SSH root password. **Required** — the build fails without it. - Needs internet access for `apt` + `pip` (Ubuntu 26.04, python3, openssh-server, Flask, psutil, tplinkrouterc6u, pycryptodome). ## 2. Run the container ```bash docker run -d --name netmonitor \ --restart unless-stopped \ -p 7080:7080 \ -p 7022:7022 \ netmonitor:latest ``` - `--restart unless-stopped` → container (and therefore sshd + netmonitor) comes back automatically after DSM reboot or container restart. In the Synology Docker GUI this is the **Autostart** checkbox. - The entrypoint starts `sshd` and the netmonitor service, then keeps the container alive. - Different web port on the host? Change the left side, e.g. `-p 80:7080`. - Different web port inside? `NETMONITOR_PORT=8080` env (or edit `config.json` before build). ## 3. Deploy to another Synology DSM Pick one path: ### A. Build directly on the target DSM (simplest) 1. Enable SSH on the target DSM: *Control Panel → Terminal & SNMP*. 2. Copy the project folder to the target (from your PC): ```bash scp -r Net-Monitor root@:/volume1/docker/ ``` (or copy via SMB/File Station to a shared folder) 3. On the target DSM: ```bash cd /volume1/docker/Net-Monitor docker build --build-arg ROOT_PASSWORD='ChangeMe-RootPass' -t netmonitor:latest . docker run -d --name netmonitor --restart unless-stopped -p 7080:7080 -p 7022:7022 netmonitor:latest ``` ### B. Build once, move the image to any DSM ```bash # on the build machine / DSM: docker save netmonitor:latest > netmonitor-image.tar # transfer: scp netmonitor-image.tar root@:/volume1/docker/ # on the target DSM: docker load < /volume1/docker/netmonitor-image.tar docker run -d --name netmonitor --restart unless-stopped -p 7080:7080 -p 7022:7022 netmonitor:latest ``` > `docker save/load` moves the **image** (reproducible). Avoid `docker export` — that snapshots a live container's filesystem and bakes in its data. ### C. Synology Docker GUI Possible for *Run* (Containers tab: name, ports, autostart), but the GUI image builder can't `COPY` local app files reliably — use the CLI build (A or B) for the image itself. ## 4. Verify ```bash docker ps # Up docker logs netmonitor | head # "NetMonitor listening on http://0.0.0.0:7080 ..." ssh root@ -p 7022 # shell works ssh root@ -p 7022 "/etc/init.d/netmonitor status" ``` Open `http://:7080` → login `sysadmin` / `pas4admin` → **Administration → Hosts** → add your SNMP / router hosts. ## 5. Day-2 operations ```bash docker exec -it netmonitor /etc/init.d/netmonitor restart # restart app only docker exec -it netmonitor tail -f /var/log/netmonitor.log # logs docker stop netmonitor && docker start netmonitor # restart container (autostart preserved) docker rm -f netmonitor # remove (image stays) ``` **Data location:** `/opt/netmonitor/data/netmonitor.db` (SQLite — users, hosts, credentials, metrics). To keep data across container recreation, mount a volume and copy the DB in once: ```bash docker run -d --name netmonitor --restart unless-stopped \ -p 7080:7080 -p 7022:7022 \ -v /volume1/docker/netmonitor-data:/opt/netmonitor/data \ netmonitor:latest # then, if migrating existing data: docker cp :/opt/netmonitor/data/netmonitor.db /volume1/docker/netmonitor-data/ docker exec netmonitor /etc/init.d/netmonitor restart ``` ## 6. Image contents (what the build installs) - Ubuntu 26.04 base, `python3` (3.14), `python3-pip`, `openssh-server` + sftp - Python deps: `Flask`, `psutil`, `tplinkrouterc6u`, `pycryptodome` - App: `app.py collector.py db.py router_pollers.py snmp_client.py` + `static/` + `docs/` - Service: `/etc/init.d/netmonitor` (SysV-style, uses `start-stop-daemon`) - Entrypoint: starts sshd + netmonitor, keeps container alive