Docker User Management¶
This guide explains how to manage users when deploying EpidBot in Docker containers.
Overview¶
When running EpidBot in Docker, user management works differently than in local deployments. This guide covers:
- Automatic Admin Creation: Default admin user created on first run
- Creating Additional Users: Using docker exec
- Managing Existing Users: Password changes, listing users
- Docker Compose Configuration: Setting up environment variables
Automatic Admin Creation¶
How It Works¶
On first startup, EpidBot automatically checks if any users exist in the database. If no users are found, it creates a default admin user using environment variables.
Configuration¶
Add these environment variables to your docker-compose.yml:
services:
epidbot:
environment:
- EPIDBOT_ADMIN_USER=admin
- EPIDBOT_ADMIN_PASSWORD=your-secure-password
- EPIDBOT_ADMIN_EMAIL=admin@example.com
Or in your .env file:
EPIDBOT_ADMIN_USER=admin
EPIDBOT_ADMIN_PASSWORD=your-secure-password
EPIDBOT_ADMIN_EMAIL=admin@example.com
Security Requirements¶
- EPIDBOT_ADMIN_PASSWORD is required (no default)
- Password must be at least 8 characters long
- Change the default password immediately after first login
First Run Behavior¶
When the container starts for the first time:
Initializing EpidBot...
INFO: Creating default admin user 'admin'...
✓ Default admin user created successfully!
User ID: 1
Username: admin
Email: admin@example.com
Credentials saved to: /data/.admin_credentials
==================================================
DEFAULT ADMIN CREDENTIALS:
Username: admin
Password: your-secure-password
==================================================
IMPORTANT: Change this password immediately!
==================================================
A credentials file is saved to /data/.admin_credentials for reference.
Creating Additional Users¶
Method 1: Using docker exec (Interactive)¶
Create users interactively:
Follow the prompts to create a new user.
Method 2: Using docker exec (Non-Interactive)¶
For automation, use heredoc:
docker exec -i epidbot uv run python auth_cli.py create-admin << EOF
researcher
secure_password_123
secure_password_123
researcher@institute.org
EOF
Method 3: Using a Script¶
Create a script create_user.sh:
Make it executable and use:
Managing Existing Users¶
List All Users¶
Output:
=== User List ===
ID Username Email Created Last Login
-----------------------------------------------------------------------------------------------
1 admin admin@example.com 2026-03-10 2026-03-10
2 researcher researcher@institute.org 2026-03-11 Never
Total: 2 user(s)
Change Password¶
Example:
Delete User¶
Example:
Docker Compose Configuration¶
Complete Example¶
version: '3.8'
services:
epidbot:
build:
context: .
dockerfile: Dockerfile
image: epidbot:latest
container_name: epidbot
ports:
- '3000:3000'
volumes:
- 'epidbot_data:/data'
environment:
# API Keys
- 'OPENAI_API_KEY=${OPENAI_API_KEY}'
- 'ZHIPU_API_KEY=${ZHIPU_API_KEY}'
- 'DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}'
- 'GOOGLE_API_KEY=${GOOGLE_API_KEY}'
# Service URLs
- 'LIBBY_URL=http://libby-api:8000'
- 'OLLAMA_HOST=http://libby-ollama:11434'
# Session Security
- 'SECRET_KEY=${SECRET_KEY}'
# Default Admin User
- 'EPIDBOT_ADMIN_USER=${EPIDBOT_ADMIN_USER:-admin}'
- 'EPIDBOT_ADMIN_PASSWORD=${EPIDBOT_ADMIN_PASSWORD}'
- 'EPIDBOT_ADMIN_EMAIL=${EPIDBOT_ADMIN_EMAIL:-admin@localhost}'
restart: unless-stopped
deploy:
resources:
limits:
cpus: '2'
memory: 4G
reservations:
cpus: '1'
memory: 2G
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
volumes:
epidbot_data:
driver: local
Environment Variables File (.env)¶
Create a .env file in the same directory as your docker-compose.yml:
# API Keys
OPENAI_API_KEY=sk-your-openai-key
ZHIPU_API_KEY=your-zhipu-key
DEEPSEEK_API_KEY=your-deepseek-key
GOOGLE_API_KEY=your-google-key
# Session Security (generate with: python -c "import secrets; print(secrets.token_hex(32))")
SECRET_KEY=your-secret-key-here
# Default Admin Credentials
EPIDBOT_ADMIN_USER=admin
EPIDBOT_ADMIN_PASSWORD=change_this_immediately
EPIDBOT_ADMIN_EMAIL=admin@yourdomain.com
Quick Reference Commands¶
Start EpidBot¶
View Logs¶
Check Default Admin Credentials¶
Create User¶
List Users¶
Change Password¶
Delete User¶
Access Application¶
Open browser to: http://localhost:3000
Login with your admin credentials.
Security Best Practices¶
1. Strong Passwords¶
Always use strong, unique passwords:
2. Change Default Password¶
Immediately after first login, change the admin password:
3. Secure SECRET_KEY¶
Generate a secure SECRET_KEY:
Add to your .env file:
4. Use Docker Secrets (Swarm)¶
For Docker Swarm, use secrets instead of environment variables:
secrets:
epidbot_admin_password:
external: true
services:
epidbot:
secrets:
- epidbot_admin_password
environment:
- EPIDBOT_ADMIN_PASSWORD_FILE=/run/secrets/epidbot_admin_password
5. Restrict Access¶
Use firewall rules to restrict access to port 3000:
6. HTTPS in Production¶
Always use HTTPS in production with a reverse proxy (Nginx, Traefik, Caddy).
Troubleshooting¶
Cannot Create Default Admin¶
Problem: Container exits with error about missing password
Solution: Set the EPIDBOT_ADMIN_PASSWORD environment variable
Cannot Login¶
Problem: "Authentication failed" when trying to login
Solutions:
-
Verify user exists:
-
Reset password:
-
Check container logs:
Database Persistence¶
Problem: Users disappear after container restart
Solution: Ensure you're using a Docker volume:
Check volume exists:
Reset Everything¶
Warning: This deletes all data!
# Stop container
docker-compose down
# Remove volume
docker volume rm epidbot_epidbot_data
# Start fresh
docker-compose up -d
Advanced Topics¶
Multiple Admins¶
Create multiple admins as needed:
# First admin (automatic)
docker-compose up -d
# Additional admins
docker exec -it epidbot uv run python auth_cli.py create-admin
Automated User Creation¶
For CI/CD or automated deployments:
#!/bin/bash
# create_users.sh
docker exec -i epidbot uv run python auth_cli.py create-admin << EOF
researcher1
password123
password123
researcher1@institute.org
EOF
docker exec -i epidbot uv run python auth_cli.py create-admin << EOF
researcher2
password456
password456
researcher2@institute.org
EOF
echo "Users created successfully"
Backup User Database¶
# Backup
docker exec epidbot sqlite3 /data/chat_history.duckdb ".backup /data/users_backup.duckdb"
# Copy to host
docker cp epidbot:/data/users_backup.duckdb ./users_backup_$(date +%Y%m%d).duckdb