Doctor Command
v0.4.8Updated for ɳSelf v0.4.8
The nself doctor command diagnoses issues with your ɳSelf installation and environment. It checks system requirements, configuration, Docker health, SSL certificates, and can automatically fix common problems.
Diagnostic Features
- - System Requirements: Docker, Docker Compose, Node.js, mkcert
- - Configuration: .env validation, port conflicts, service dependencies
- - Docker Health: Daemon status, container health, resource usage
- - SSL Certificates: Validity, trust status, expiration
- - Auto-Fix: Automatically resolve common issues
Usage
nself doctor [options]
Options
| Option | Description | Default |
|---|
--fix | Automatically fix detected issues | false |
--verbose, -v | Show detailed diagnostic output | false |
--json | Output results in JSON format | false |
--category CAT | Check specific category only | all |
--skip CHECKS | Skip specific checks (comma-separated) | none |
--env NAME | Check specific environment | current |
Diagnostic Categories
| Category | Checks Performed |
|---|
system | Docker, Docker Compose, Node.js, mkcert, OS compatibility |
config | .env validation, required variables, port conflicts |
docker | Daemon status, container health, networks, volumes |
ssl | Certificate validity, trust status, expiration |
network | Port availability, DNS resolution, connectivity |
services | Service health, dependencies, configuration |
Examples
Full Diagnostic
# Run all checks
nself doctor
# Output:
➞ ɳSelf Doctor - Diagnosing your installation...
System Requirements
-------------------
✓ Docker 24.0.7 installed (minimum: 20.10)
✓ Docker Compose 2.23.0 installed (minimum: 2.0)
✓ Docker daemon is running
✓ Node.js 20.10.0 installed (minimum: 18.0)
✓ mkcert installed
Configuration
-------------
✓ .env file found
✓ PROJECT_NAME configured
✓ BASE_DOMAIN configured
✓ Required secrets present
! Warning: POSTGRES_PASSWORD is weak (< 12 chars)
✓ No port conflicts detected
Docker Health
-------------
✓ Docker daemon healthy
✓ 5 containers running
✓ All containers healthy
✓ Docker networks configured
✓ Docker volumes intact
SSL Certificates
----------------
✓ Certificate valid for local.nself.org
✓ Certificate trusted in system
✓ Expires in 364 days
Network
-------
✓ Port 80 available
✓ Port 443 available
✓ DNS resolves local.nself.org -> 127.0.0.1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Summary: 18 passed, 1 warning, 0 failed
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ 1 warning detected. Run 'nself doctor --fix' to resolve.
Auto-Fix Issues
# Automatically fix detected issues
nself doctor --fix
# Output:
➞ ɳSelf Doctor - Auto-fixing issues...
✗ Docker daemon not running
→ Starting Docker daemon... ✓
✗ SSL certificate expired
→ Regenerating certificates... ✓
→ Installing in trust store... ✓
✗ Port 80 in use by another process
→ Cannot auto-fix: Stop the conflicting process manually
✓ Fixed 2 of 3 issues
! 1 issue requires manual intervention
Check Specific Category
# Check only SSL certificates
nself doctor --category ssl
# Check only Docker health
nself doctor --category docker
# Check only configuration
nself doctor --category config
Verbose Output
nself doctor --verbose
# Shows additional details:
# - Exact version numbers
# - File paths checked
# - Network diagnostic details
# - Resource usage statistics
Check Details
System Requirements Checks
| Check | Requirement | Auto-Fix |
|---|
| Docker | Version 20.10+ | No (install required) |
| Docker Compose | Version 2.0+ | No (install required) |
| Docker Daemon | Running | Yes (start daemon) |
| Node.js | Version 18.0+ | No (install required) |
| mkcert | Installed | Yes (brew install) |
| Disk Space | 5GB+ available | No (manual cleanup) |
Configuration Checks
| Check | Description | Auto-Fix |
|---|
| .env exists | Configuration file present | Yes (create from template) |
| Required variables | PROJECT_NAME, BASE_DOMAIN set | No (user input required) |
| Port conflicts | No duplicate port assignments | No (user choice) |
| Password strength | Passwords 12+ chars | Yes (regenerate secrets) |
| Service dependencies | Dependencies satisfied | Yes (enable missing) |
Docker Health Checks
| Check | Description | Auto-Fix |
|---|
| Daemon status | Docker daemon running | Yes (start daemon) |
| Container health | All containers healthy | Yes (restart unhealthy) |
| Networks | Required networks exist | Yes (create networks) |
| Volumes | Volumes intact | No (data loss risk) |
| Resource usage | Memory/CPU within limits | No (user decision) |
SSL Certificate Checks
| Check | Description | Auto-Fix |
|---|
| Certificate exists | SSL cert files present | Yes (regenerate) |
| Certificate valid | Not expired, valid for domain | Yes (regenerate) |
| Certificate trusted | Installed in system trust | Yes (ɳSelf trust) |
| Domain coverage | Covers all required domains | Yes (regenerate) |
| Expiration warning | 30+ days until expiry | Yes (renew) |
Network Checks
| Check | Description | Auto-Fix |
|---|
| Port 80 available | HTTP port not in use | No (stop conflicting) |
| Port 443 available | HTTPS port not in use | No (stop conflicting) |
| DNS resolution | Domain resolves correctly | No (DNS config) |
| Localhost resolution | *.local.nself.org → 127.0.0.1 | No (DNS config) |
JSON Output
Get machine-readable output for scripting:
nself doctor --json
# Output:
{
"timestamp": "2026-01-24T10:30:00Z",
"summary": {
"passed": 18,
"warnings": 1,
"failed": 0,
"total": 19
},
"categories": {
"system": {
"status": "passed",
"checks": [
{
"name": "docker_version",
"status": "passed",
"message": "Docker 24.0.7 installed",
"details": { "version": "24.0.7", "minimum": "20.10" }
}
]
},
"config": {
"status": "warning",
"checks": [
{
"name": "password_strength",
"status": "warning",
"message": "POSTGRES_PASSWORD is weak",
"fixable": true
}
]
}
}
}
Skip Specific Checks
# Skip SSL checks (useful in CI environments)
nself doctor --skip ssl
# Skip multiple categories
nself doctor --skip ssl,network
# Skip specific checks
nself doctor --skip docker_daemon,port_80
Environment-Specific Diagnostics
# Check staging environment
nself doctor --env staging
# Check production environment
nself doctor --env prod
# Different checks may apply:
# - Production: SSL must be Let's Encrypt
# - Production: DEBUG must be disabled
# - Production: Stronger password requirements
Exit Codes
| Code | Meaning |
|---|
| 0 | All checks passed |
| 1 | Warnings detected (non-critical) |
| 2 | Errors detected (critical issues) |
| 3 | Doctor command failed to run |
Common Issues and Solutions
Docker Daemon Not Running
# Check detected:
✗ Docker daemon not running
# Auto-fix:
nself doctor --fix
# Or manually:
open -a Docker # macOS
sudo systemctl start docker # Linux
SSL Certificate Not Trusted
# Check detected:
✗ Certificate not trusted in system
# Auto-fix:
nself doctor --fix
# Or manually:
ɳSelf trust
Port Already in Use
# Check detected:
✗ Port 80 in use by process: nginx (pid 1234)
# Manual fix required:
# Option 1: Stop the conflicting process
sudo kill 1234
# Option 2: Change the port in .env
HTTP_PORT=8080
HTTPS_PORT=8443
Weak Passwords
# Check detected:
! POSTGRES_PASSWORD is weak (< 12 chars)
# Auto-fix:
nself doctor --fix
# Regenerates secrets with strong passwords
# Or manually regenerate:
ɳSelf prod secrets generate
Missing Configuration
# Check detected:
✗ .env file not found
# Auto-fix:
nself doctor --fix
# Creates .env from .env.example
# Or manually:
cp .env.example .env
# Then edit with your configuration
CI/CD Integration
# In GitHub Actions or CI pipeline:
- name: Check nself health
run: |
nself doctor --json > doctor-report.json
if [ $? -eq 2 ]; then
echo "Critical issues detected"
cat doctor-report.json
exit 1
fi
# Skip network checks in CI (no localhost DNS)
- name: Check ɳSelf (CI mode)
run: nself doctor --skip network,ssl
Related Commands