Docker Compose Deployment Guide¶
⚠️ Version Requirement: Docker Compose v2.0+ is required. Use docker compose
(space), not docker-compose
(hyphen).
This guide covers deploying KrakenHashes using Docker Compose, including configuration options, network setup, volume management, and common customizations.
Table of Contents¶
- Overview
- Prerequisites
- Configuration Options
- Network Setup
- Volume Management
- Deployment Steps
- Scaling Considerations
- Common Customizations
- Troubleshooting
- Security Considerations
Overview¶
KrakenHashes uses Docker Compose to orchestrate multiple services:
- PostgreSQL: Database backend for storing hashlists, jobs, and system data
- KrakenHashes App: Combined backend API and frontend served through nginx
The Docker Compose setup provides: - Automatic service dependency management - Health checks for service readiness - Persistent data storage through Docker volumes - Environment-based configuration - Isolated networking
Prerequisites¶
Before deploying with Docker Compose:
- Docker Engine: Version 20.10 or higher
- Docker Compose: Version 2.0 or higher (included with Docker Desktop)
- System Requirements:
- 4GB RAM minimum (8GB recommended)
- 10GB free disk space
-
Linux, macOS, or Windows with WSL2
-
Network Ports:
- 443 (HTTPS frontend)
- 1337 (HTTP API)
- 31337 (HTTPS API)
- 5432 (PostgreSQL - optional, can be internal only)
Configuration Options¶
Environment Variables¶
Create a .env
file in the project root with the following variables:
# Database Configuration
DB_USER=krakenhashes
DB_PASSWORD=your-secure-password
DB_NAME=krakenhashes
# Port Configuration
FRONTEND_PORT=443
KH_PORT=1337
KH_HTTPS_PORT=31337
# Directory Configuration
LOG_DIR=/var/log/krakenhashes
KH_CONFIG_DIR_HOST=/etc/krakenhashes
KH_DATA_DIR_HOST=/var/lib/krakenhashes
# User/Group IDs (for file permissions)
PUID=1000
PGID=1000
# TLS Configuration
KH_TLS_MODE=self-signed
KH_CERT_KEY_SIZE=4096
KH_CERT_VALIDITY_DAYS=365
KH_CA_VALIDITY_DAYS=3650
Service-Specific Configuration¶
PostgreSQL Service¶
The PostgreSQL service is configured with: - Alpine-based image for smaller footprint - Health checks using pg_isready
- Persistent data storage in Docker volume - Configurable credentials via environment variables
KrakenHashes Application¶
The main application container includes: - Multi-stage build for optimized image size - Combined backend and frontend services - nginx reverse proxy for frontend - TLS/SSL support with multiple modes - File storage for binaries, wordlists, and hashlists
Network Setup¶
Default Network¶
Docker Compose creates an isolated bridge network krakenhashes-net
:
This provides: - Service discovery by container name - Isolation from other Docker networks - Internal DNS resolution
Service Communication¶
- Backend connects to PostgreSQL using hostname
postgres
- All services communicate over the internal network
- Only required ports are exposed to the host
Custom Network Configuration¶
To use an existing network or customize settings:
Or with custom subnet:
networks:
krakenhashes-net:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
gateway: 172.20.0.1
Volume Management¶
Persistent Volumes¶
KrakenHashes uses named volumes for data persistence:
- postgres_data: PostgreSQL database files
- krakenhashes_data: Application data (wordlists, rules, hashlists)
Volume Locations¶
Default volume storage locations: - Docker managed: /var/lib/docker/volumes/
- Named volumes: - krakenhashes_postgres_data
- krakenhashes_app_data
Bind Mounts¶
The compose file uses bind mounts for: - Logs: ${LOG_DIR:-/var/log/krakenhashes}
- Config: ${KH_CONFIG_DIR_HOST:-/etc/krakenhashes}
- Data: ${KH_DATA_DIR_HOST:-/var/lib/krakenhashes}
Backup Strategy¶
To backup volumes:
# Backup PostgreSQL data
docker run --rm -v krakenhashes_postgres_data:/data \
-v $(pwd):/backup alpine tar czf /backup/postgres-backup.tar.gz -C /data .
# Backup application data
docker run --rm -v krakenhashes_app_data:/data \
-v $(pwd):/backup alpine tar czf /backup/app-backup.tar.gz -C /data .
Deployment Steps¶
Initial Deployment¶
-
Clone the repository:
-
Create environment file:
-
Create required directories:
-
Build and start services:
-
Verify deployment:
Updating Deployment¶
-
Pull latest changes:
-
Rebuild and restart:
-
Check migration status:
Scaling Considerations¶
Horizontal Scaling¶
While the current setup runs as a single instance, you can prepare for scaling:
- Database Scaling:
- Use external PostgreSQL for production
- Consider connection pooling with PgBouncer
-
Implement read replicas for reporting
-
Application Scaling:
- Use external load balancer (nginx, HAProxy)
- Share file storage (NFS, S3-compatible)
- Implement Redis for session storage
Resource Limits¶
Add resource constraints to prevent container resource exhaustion:
services:
krakenhashes:
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G
Common Customizations¶
Development Mode¶
For development, uncomment restart policies and expose additional ports:
services:
postgres:
restart: unless-stopped
ports:
- "5432:5432" # Direct database access
krakenhashes:
restart: unless-stopped
environment:
- DEBUG=true
- LOG_LEVEL=debug
Production Optimizations¶
-
Remove unnecessary port exposures:
-
Enable restart policies:
-
Use specific image tags:
Custom TLS Certificates¶
To use your own certificates:
- Place certificates in
/etc/krakenhashes/certs/
- Set environment variables:
External Database¶
To use an external PostgreSQL instance:
- Remove the postgres service from docker-compose.yml
- Update environment variables:
Troubleshooting¶
Common Issues¶
-
Container fails to start:
-
Database connection errors:
-
Permission issues:
-
Port conflicts:
Debug Mode¶
Enable debug logging:
Health Checks¶
Monitor service health:
# Check all services
docker-compose ps
# Detailed health info
docker inspect krakenhashes-postgres | jq '.[0].State.Health'
Security Considerations¶
Network Security¶
- Firewall Rules:
- Only expose necessary ports
- Use firewall to restrict access
-
Consider VPN for administrative access
-
TLS/SSL:
- Always use HTTPS in production
- Regularly update certificates
- Use strong cipher suites
Container Security¶
- Run as non-root:
- Containers use UID/GID 1000 by default
-
Avoid running as root user
-
Image Security:
-
Secrets Management:
- Use Docker secrets for sensitive data
- Rotate database passwords regularly
- Never commit .env files to version control
Backup and Recovery¶
-
Regular Backups:
# Automated backup script #!/bin/bash BACKUP_DIR="/backup/krakenhashes/$(date +%Y%m%d)" mkdir -p $BACKUP_DIR # Backup database docker-compose exec -T postgres pg_dump -U krakenhashes > $BACKUP_DIR/database.sql # Backup volumes docker run --rm -v krakenhashes_app_data:/data \ -v $BACKUP_DIR:/backup alpine \ tar czf /backup/app-data.tar.gz -C /data .
-
Test Recovery:
- Regularly test backup restoration
- Document recovery procedures
- Keep multiple backup generations
Monitoring¶
Implement monitoring for: - Container health and restarts - Resource usage (CPU, memory, disk) - Application logs and errors - Database performance - TLS certificate expiration
Consider using: - Prometheus + Grafana for metrics - ELK stack for log aggregation - Uptime monitoring services