Netdot (the Network Documentation Tool) in Docker with a single image based on centos:7.9.2009
57
Run Netdot (the Network Documentation
Tool) in Docker: a single centos:7.9.2009-based image with Apache + mod_perl
and a MySQL-compatible database, fronted by an nginx reverse proxy that
terminates TLS. The install follows DigitalOcean's
How To Document Your Network with Netdot on CentOS 7 tutorial.
*.sql / *.sql.gz dumps from an existing Netdot
installation into the running container.verify.sh logs in through the proxy to prove the
whole stack works. browser ──443/80──▶ nginx (TLS) ──HTTP──▶ netdot container
├─ Apache + mod_perl (Netdot)
└─ MariaDB 5.5 (socket only)
Database server: the image runs MariaDB 5.5 from the CentOS 7 base repositories — the MySQL-compatible server CentOS 7 ships (Netdot's
DB_TYPEismysql). Oracle's MySQL 5.7 Community repository is not used.
docker compose) and BuildKitopenssl and curl (certificate generation and verification)mirrors.aliyun.com (CentOS vault + EPEL archive),
github.com (Netdisco MIBs, DNSSEC-Tools) and cpan.org at build time.
The CentOS 7 mirrors can be changed with --build-arg MIRROR=....git clone <this-repo-url> netdot-docker && cd netdot-docker
git clone https://github.com/cvicente/Netdot.git Netdot # the app source (build context)
./gen-certs.sh # self-signed cert in ./certs (or supply your own)
docker compose up -d --build # first build takes a while
./verify.sh # scripted login through nginx -> PASS
Open https://localhost/netdot/ and sign in with admin / admin.
Change that password immediately, along with the database passwords below.
If ports 80/443 are taken on the host:
HTTP_PORT=8081 HTTPS_PORT=8443 docker compose up -d --build
BASE_URL=https://localhost:8443/netdot HTTP_URL=http://localhost:8081 ./verify.sh
Environment variables (set them in the shell or an .env file next to
docker-compose.yml):
| Variable | Default | Purpose |
|---|---|---|
DB_DBA_PASSWORD | rootpass | Database root password |
DB_NETDOT_USER | netdot_user | Application database user |
DB_NETDOT_PASS | netdot_pass | Application database password |
DB_DATABASE | netdot | Database name |
HTTP_PORT | 80 | Host port for HTTP (redirects to HTTPS) |
HTTPS_PORT | 443 | Host port for HTTPS |
CERT_DIR | ./certs | Directory holding fullchain.pem and privkey.pem |
DB_IMPORT_FILE | (unset) | Dump to import on first start (see below) |
Avoid ' characters in passwords: they are written into Netdot's Site.conf
and SQL statements unescaped.
./gen-certs.sh creates a self-signed certificate (CN localhost). For a real
certificate put fullchain.pem and privkey.pem in certs/ (or point
CERT_DIR at them). Apache inside the image serves plain HTTP only; there is
no mod_ssl, and only nginx publishes ports.
The database lives in the netdot-db volume (/var/lib/mysql). It is
initialised on first start (make installdb) and reused afterwards.
Migrate a database from a working Netdot system into the running container.
Supported files: *.sql and *.sql.gz.
On the source system, create a dump:
mysqldump --single-transaction netdot | gzip > netdot.sql.gz
Import it into the running container:
docker cp netdot.sql.gz netdot-docker-netdot-1:/tmp/
docker exec netdot-docker-netdot-1 \
/docker-entrypoint.sh import --replace --upgrade /tmp/netdot.sql.gz
(Use docker compose ps for the actual container name.)
Behaviour:
--replace; with --replace it first writes
pre-import-<timestamp>.sql.gz to /var/lib/mysql/ as a backup..sql/.sql.gz only, gzip
integrity checked); a load error aborts with the MySQL message.--upgrade runs Netdot's make upgrade for dumps from older Netdot
versions; a dump already at the current schema is left alone. Back up first —
see Netdot's doc/UPGRADE.*.sql / *.sql.gz in /docker-entrypoint-initdb.d/
(mount a directory there) or the file named by DB_IMPORT_FILE are imported
instead of running make installdb, once, when the database does not exist.Limitations: the server is MariaDB 5.5, so dumps from MySQL 8.0 that use
utf8mb4_0900_* collations or other 8.0-only syntax will not load (MySQL 5.x
and MariaDB dumps are fine). The dump's database name must match DB_DATABASE.
builder stage compiles/installs all Perl dependencies;
the runtime stage carries only runtime packages plus /usr/local.rfc net-snmp cisco; add vendors with
--build-arg MIB_DIRS="rfc net-snmp cisco juniper".crond is not run, and snmpd is not
started. Run scheduled Netdot jobs from the host or an extra container if you
need them.X-Forwarded-For from private networks (mod_remoteip), so
Netdot sees client addresses behind the proxy../verify.sh # login through nginx (wrong password rejected,
# admin/admin accepted, HTTP -> HTTPS 301)
./tests/test-import.sh # import feature, against real containers
# (IMAGE=netdot:local PORT=8082 by default)
| Path | Purpose |
|---|---|
Dockerfile | Multi-stage image build |
docker-entrypoint.sh | Starts MariaDB and Apache; import subcommand |
docker-compose.yml | netdot + nginx services |
nginx/netdot.conf.template | nginx TLS/proxy config (rendered with envsubst) |
docker/ | my.cnf, remoteip.conf |
gen-certs.sh | Self-signed certificate helper |
verify.sh, tests/ | Verification and tests |
docs/superpowers/ | Design specs and implementation plan |
Netdot/ | Netdot source (clone it here; tested with d8346626) |
admin/admin, rootpass, netdot_pass) are for
getting started only — change them before exposing the service.skip-networking); it is not
reachable over TCP, even from other containers.Netdot is licensed under the GPL. This project is licensed under the MIT License.
| Author | Masoud Maghsoudi |
|---|---|
| [email protected] | |
| Github | https://github.com/masoud-maghsoudi |
Content type
Image
Digest
sha256:0c56845b6…
Size
226.9 MB
Last updated
10 days ago
docker pull shaspen/netdot:centos-7