Docker Deployment¶
Deploy Trunk8 using Docker for easy installation and management. This guide covers building, running, and configuring Trunk8 in Docker containers.
Quick Start¶
Pull and Run¶
The fastest way to get started:
Access Trunk8 at http://localhost:5001
.
Build from Source¶
Clone and build the Docker image:
Run the container:
Docker Image Details¶
The Trunk8 Docker image uses:
- Base Image:
ghcr.io/astral-sh/uv:python3.12-bookworm-slim
- Package Manager: uv for fast dependency installation
- Web Server: Gunicorn
- Port: 5001 (exposed and served)
Configuration¶
Environment Variables¶
Configure Trunk8 using environment variables:
docker run -p 5001:5001 \
-e TRUNK8_ADMIN_PASSWORD="your-secure-password" \
-e TRUNK8_SECRET_KEY="your-secret-key" \
-e TRUNK8_PORT="5001" \
trunk8
Available environment variables:
Variable | Description | Default |
---|---|---|
TRUNK8_ADMIN_PASSWORD |
Admin login password | admin |
TRUNK8_SECRET_KEY |
Flask session secret key | your-secret-key-change-in-production |
TRUNK8_PORT |
Port for Flask development server | 5001 |
Using an .env File¶
Create a .env
file:
TRUNK8_ADMIN_PASSWORD=my-secure-password
TRUNK8_SECRET_KEY=my-secret-key-for-sessions
TRUNK8_PORT=5001
Run with the env file:
Persistent Storage¶
To persist data between container restarts, mount volumes for:
- User data (
users/
directory containing user accounts and links) - Configuration files (
config/
directory containing app and theme settings)
Using Docker Volumes¶
Create named volumes:
Run with volumes:
Using Bind Mounts¶
Mount local directories:
Docker Compose¶
For easier management, use Docker Compose:
docker-compose.yml¶
version: '3.8'
services:
trunk8:
image: ghcr.io/lancereinsmith/trunk8:latest
ports:
- "5001:5001"
environment:
- TRUNK8_ADMIN_PASSWORD=${TRUNK8_ADMIN_PASSWORD:-admin}
- TRUNK8_SECRET_KEY=${TRUNK8_SECRET_KEY}
volumes:
- trunk8-users:/app/users
- trunk8-config:/app/config
restart: unless-stopped
volumes:
trunk8-users:
trunk8-config:
Running with Docker Compose¶
Start the service:
View logs:
Stop the service:
Production Deployment¶
Using a Reverse Proxy¶
For production, use a reverse proxy like Nginx:
nginx.conf¶
server {
listen 80;
server_name trunk8.example.com;
location / {
proxy_pass http://localhost:5001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
HTTPS with Let's Encrypt¶
Use Certbot for automatic HTTPS:
Complete Production Stack¶
Create a docker-compose.prod.yml
:
version: '3.8'
services:
trunk8:
image: ghcr.io/lancereinsmith/trunk8:latest
environment:
- TRUNK8_ADMIN_PASSWORD=${TRUNK8_ADMIN_PASSWORD}
- TRUNK8_SECRET_KEY=${TRUNK8_SECRET_KEY}
volumes:
- trunk8-users:/app/users
- trunk8-config:/app/config
restart: always
networks:
- trunk8-network
nginx:
image: nginx:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- certbot-etc:/etc/letsencrypt
- certbot-var:/var/lib/letsencrypt
depends_on:
- trunk8
restart: always
networks:
- trunk8-network
networks:
trunk8-network:
volumes:
trunk8-users:
trunk8-config:
certbot-etc:
certbot-var:
Backup and Restore¶
Backup¶
Backup user data and configuration:
# Create backup directory
mkdir -p backups/$(date +%Y%m%d)
# Backup volumes
docker run --rm \
-v trunk8-users:/users \
-v trunk8-config:/config \
-v $(pwd)/backups:/backup \
alpine tar czf /backup/$(date +%Y%m%d)/trunk8-backup.tar.gz /users /config
Restore¶
Restore from backup:
# Restore volumes
docker run --rm \
-v trunk8-users:/users \
-v trunk8-config:/config \
-v $(pwd)/backups:/backup \
alpine tar xzf /backup/20240101/trunk8-backup.tar.gz -C /
Container Management¶
View Container Logs¶
Access Container Shell¶
Monitor Resource Usage¶
Update Container¶
Pull the latest image and recreate:
docker pull ghcr.io/lancereinsmith/trunk8:latest
docker stop trunk8
docker rm trunk8
docker run -p 5001:5001 --name trunk8 ghcr.io/lancereinsmith/trunk8:latest
Troubleshooting¶
Container Won't Start¶
Check logs for errors:
Common issues: - Port 5001 already in use - Permission issues with volumes - Invalid environment variables
Permission Issues¶
Fix volume permissions:
Network Issues¶
Ensure the container can reach external services:
Performance Tuning¶
Adjust Gunicorn workers in Dockerfile:
Security Considerations¶
- Always set secure passwords for
TRUNK8_ADMIN_PASSWORD
- Use HTTPS in production with proper certificates
- Limit exposed ports using firewall rules
- Regular updates - Pull latest images frequently
- Resource limits - Set memory and CPU limits:
Next Steps¶
- Configure Environment Variables
- Set up Production Deployment
- Learn about Backup Strategies
- Implement Security Best Practices