Brain Structural Validation / Validate Markdown Structure & Links (push) Successful in 6s
9.5 KiB
9.5 KiB
type, project, date, tags
| type | project | date | tags | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| debug | homelab | 2026-09-22 |
|
Incident RCA & System Integration: Diun Docker Provider Connectivity & Stalwart Mail Notification
System Context & Fundamentals
The roadtotech.me homelab Core platform runs several platform and monitoring services inside a unified Docker Compose stack (~/Core/docker-compose.yml), orchestrated under NixOS.
socket-proxy: A security barrier running HAProxy that exposes a strictly read-only Docker API subset (POST=0,DELETE=0) on the isolatedsocket-netnetwork attcp://socket-proxy:2375.diun(Docker Image Update Notifier): An autonomous scanner designed to inspect running containers, query remote image registries (Docker Hub, GHCR, Quay) for updated image digests/tags, and publish update notifications.stalwart: An all-in-one mail server handling inbound/outbound SMTP (25, 465, 587) and IMAPS (993) onproxy-net, using LLDAP for user authentication.
Problem & Observations
The operator reported that Diun was failing to connect to the homelab infrastructure. Container logs displayed the following recurring pattern:
diun | INF Starting Diun version=v4.33.0
diun | INF Configuration loaded from 5 environment variable(s)
diun | WRN No notifier available
diun | INF Cron triggered
diun | INF gRPC server listening addr=[::]:42286
diun | ERR Cannot create Docker client error="Cannot connect to the Docker daemon at tcp://socket-proxy:2375. Is the docker daemon running?" provider=docker
diun | WRN No image found
diun | INF Jobs completed added=0 failed=0 skipped=0 unchanged=0 updated=0
diun | INF Cron initialized with schedule 0 */6 * * *
diun | INF Next run in 5 hours
...
diun | INF Cron triggered
diun | WRN No image found
diun | INF Jobs completed added=0 failed=0 skipped=0 unchanged=0 updated=0
Initial Symptoms:
- Startup Error:
ERR Cannot create Docker client error="Cannot connect to the Docker daemon at tcp://socket-proxy:2375. Is the docker daemon running?" - Zero Tracked Images:
WRN No image foundwithJobs completed added=0 failed=0 skipped=0 unchanged=0 updated=0across all scheduled cron triggers. - No Alerting Channel:
WRN No notifier available.
Diagnostic Inquiries
- Is
socket-proxyreachable from thediuncontainer over thesocket-netbridge? - Why does the Docker client creation error occur at startup, yet subsequent cron runs attempt execution?
- Why does Diun discover zero container images during its cron execution?
- How can Diun dispatch notifications to
kiskaadee@roadtotech.methrough the local Stalwart mail service without compromising spam filtering or relay boundaries?
Investigation & Hypothesis Testing
1. Inspecting Socket Proxy Access Logs
- Command:
ssh server-local "docker logs --tail 50 socket-proxy" - Evidence:
::ffff:172.19.0.2:39952 [22/Sep/2026:12:00:20.621] dockerfrontend dockerbackend/dockersocket ... "HEAD /_ping HTTP/1.1" 200 ::ffff:172.19.0.2:39952 [22/Sep/2026:12:00:20.622] dockerfrontend dockerbackend/dockersocket ... "GET /v1.54/version HTTP/1.1" 200 ::ffff:172.19.0.2:39952 [22/Sep/2026:12:00:20.628] dockerfrontend dockerbackend/dockersocket ... "GET /v1.54/containers/json?filters=%7B%22status%22%3A%7B%22running%22%3Atrue%7D%7D HTTP/1.1" 200 ::ffff:172.19.0.2:39952 [22/Sep/2026:12:00:20.655] dockerfrontend dockerbackend/dockersocket ... "GET /v1.54/images/amir20/dozzle:latest/json HTTP/1.1" 200 - Status: Refutes total network disconnection. Diun was successfully querying container lists and image metadata on scheduled cron runs, but failed during initial container startup.
2. Startup Race Condition
- Rationale: Compose services without explicit dependencies initialize in parallel.
- Evidence:
diunindocker-compose.ymllacked adepends_on: [socket-proxy]directive. At container initialization, Diun immediately pinged port 2375 before HAProxy finished binding its listener socket. - Status: Confirmed as root cause for the startup
ERR Cannot create Docker client.
3. Container Label Filter Invariant
- Rationale: Diun's Docker provider documentation specifies that
watchByDefaultdefaults tofalse. Whenfalse, containers withoutdiun.enable=trueare ignored. - Evidence: Grepping the repository for
diun.enableyielded 0 results. Diun inspected all containers viasocket-proxy, found none with the label, and loggedWRN No image found. - Status: Confirmed as root cause for zero analyzed images.
4. Stalwart SMTP Integration & Anti-Spam Evaluation
- Diagnostic: Tested internal SMTP communication from
proxy-nettostalwart:25using a Python container script:s = smtplib.SMTP("stalwart", 25) s.mail("diun@roadtotech.me") print(s.rcpt("kiskaadee@roadtotech.me")) # (250, b'2.1.5 OK') print(s.rcpt("fcortesbio@gmail.com")) # (550, b'5.1.2 Relay not allowed.') - Findings:
- Unauthenticated local delivery on port 25 to
@roadtotech.mesucceeds natively. - Unauthenticated relaying to external domains (
@gmail.com) is blocked to prevent open mail relaying. - Direct test emails landed in SnappyMail's
Junkfolder because the test client sent unauthenticated internal mail claiming@roadtotech.mewith bare headers and default container hostnames (diun/ container ID) rather than an RFC-compliant FQDN EHLO domain. - Explicitly configuring
DIUN_NOTIF_MAIL_LOCALNAME=roadtotech.mesatisfies the SMTP HELO/EHLO validation policy on Stalwart.
- Unauthenticated local delivery on port 25 to
Findings & Root Cause Analysis
- Startup Dependency Gap: Diun failed on boot due to missing
depends_on: [socket-proxy]. - Opt-in Filtering: Diun ignored running containers because
DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULTwas unset (defaultfalse). - Missing Notifier Definition: Diun operated without notification backends configured.
- SMTP EHLO Hostname Validation: Stalwart required a valid domain for EHLO handshakes, requiring
DIUN_NOTIF_MAIL_LOCALNAMEto avoid550 5.5.0 Invalid EHLO domainrejection.
Declarative Remediation & Local Validation
In ~/Core/docker-compose.yml, updated the diun service configuration:
diun:
image: crazymax/diun:latest
container_name: diun
restart: always
command: serve
depends_on:
- socket-proxy
- stalwart
environment:
- TZ=UTC
- LOG_LEVEL=info
- LOG_JSON=false
- DIUN_WATCH_WORKERS=20
- DIUN_WATCH_SCHEDULE=0 */6 * * *
- DIUN_PROVIDERS_DOCKER=true
- DIUN_PROVIDERS_DOCKER_ENDPOINT=tcp://socket-proxy:2375
- DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULT=true
- DIUN_PROVIDERS_DOCKER_APIVERSION=${DOCKER_API_VERSION:-1.40}
- DIUN_NOTIF_MAIL_HOST=stalwart
- DIUN_NOTIF_MAIL_PORT=25
- DIUN_NOTIF_MAIL_LOCALNAME=${DOMAIN:-roadtotech.me}
- DIUN_NOTIF_MAIL_SSL=false
- DIUN_NOTIF_MAIL_INSECURESKIPVERIFY=true
- DIUN_NOTIF_MAIL_FROM=diun@${DOMAIN:-roadtotech.me}
- DIUN_NOTIF_MAIL_TO=kiskaadee@${DOMAIN:-roadtotech.me}
volumes:
- ./config/diun:/data
networks:
- socket-net
- proxy-net
Local Validation
Executed ./scripts/test on the workstation:
- Ruff linting passed.
- Pytest security invariants (socket-proxy read-only enforcement, unprivileged container checks) passed (35/35).
- Nix flake evaluation passed.
Deployment & Recovery Runbook
- Commit & Push:
git commit -am "feat(core): configure diun mail notifications via stalwart" git push origin main - Pull & Recreate on Server:
ssh server-local "cd ~/Core && git pull && appctl up diun" - Trigger Notification Test:
ssh server-local "docker exec diun diun notif test" - Post-Deployment Verification:
- Diun logs:
INF Configuration loaded from 13 environment variable(s) INF Found 22 image(s) to analyze provider=docker INF Jobs completed added=0 failed=3 skipped=0 unchanged=19 updated=0 Notification sent for mail notifier(s) - Stalwart logs:
INFO Delivery completed (delivery.completed) queueId = 330944359985840128 queueName = "local" from = "diun@roadtotech.me" to = ["kiskaadee@roadtotech.me"] code = 250
- Diun logs:
Discussion & Generalization
- Log Illusion vs. Transient Failure: An error occurring only during the container's entrypoint initialization must be distinguished from ongoing operational failure. Inspecting access logs on the target service (
socket-proxy) immediately showed that scheduled cron requests were healthy. - Default-Deny Filters in Daemon Notifiers: Daemon monitoring tools (Diun, Watchtower) frequently default to label-only discovery. Explicitly defining global watch behavior (
watchByDefault: true) is necessary in homelab architectures where services are deployed via individual compose files without centralized label boilerplate. - Internal Mail Server Anti-Spoofing: Internal microservices delivering unauthenticated alerts over port 25 to local mailboxes must provide valid EHLO domains (
localName) to pass MTA ingress checks and prevent false-positive spam flagging.
References
- Core Manifest:
/home/kiskaadee/Homelab/Core/docker-compose.yml - Diun Documentation: https://crazymax.dev/diun/
- Stalwart Mail Server: https://stalw.art/docs/