Overview
Docker deployment provides an isolated, reproducible environment for running nanobot. The official Docker image includes all dependencies, including Node.js 20 for the WhatsApp bridge.The
-v ~/.nanobot:/root/.nanobot flag mounts your local config directory into the container, ensuring your configuration and workspace persist across container restarts.Docker Compose (Recommended)
Docker Compose is the easiest way to deploy nanobot with proper resource limits and automatic restarts.Setup
Create docker-compose.yml
Create a
docker-compose.yml file in your project directory:docker-compose.yml
Initialize configuration
Run the onboard command to create your initial configuration:This creates
~/.nanobot/config.json on your host system.Common Operations
Docker (Standalone)
For manual Docker deployments without Compose:Build the Image
Initialize and Configure
Run the Gateway
Run CLI Commands
OAuth Providers (OpenAI Codex)
For providers that require OAuth login (like OpenAI Codex), you need interactive terminal access:Resource Limits
The Docker Compose configuration includes sensible resource limits:- CPU: Up to 1 core, minimum 0.25 cores reserved
- Memory: Up to 1GB, minimum 256MB reserved
Networking
Port Mapping
The gateway exposes port 18790 by default:Network Isolation
For production deployments with multiple services:Volumes and Persistence
Configuration Directory
The~/.nanobot directory contains:
config.json- Main configurationworkspace/- Agent workspace, memory, and session filesworkspace/MEMORY.md- Persistent agent memoryworkspace/HEARTBEAT.md- Periodic tasksworkspace/cron/- Scheduled job storage.whatsapp-session/- WhatsApp session data (if using WhatsApp)matrix-store/- Matrix E2EE keys (if using Matrix)
Custom Volume Paths
Environment Variables
You can override config values using environment variables:- Provider keys:
{PROVIDER}_API_KEY(e.g.,OPENROUTER_API_KEY,ANTHROPIC_API_KEY) - See the Configuration reference for all available variables
Multi-Instance Deployment
Run multiple isolated nanobot instances:docker-compose.yml
- Configuration file
- Workspace directory
- Session storage
- Port binding
Health Checks
Add health checks to your Docker Compose configuration:Troubleshooting
Container Won’t Start
- Missing API keys in
config.json - Invalid JSON in configuration file
- Port 18790 already in use
Config Changes Not Applied
Restart the container after editingconfig.json:
Permission Issues
Ensure the volume mount has correct permissions:Gateway Can’t Connect to Channels
- Check if channels are enabled in
config.json - Verify API tokens/credentials are correct
- Check network connectivity:
WhatsApp Bridge Issues
If using WhatsApp, the bridge runs on port 3001 inside the container:Memory Issues
If the container is killed due to OOM:Rebuild After Source Changes
Security Best Practices
Use secrets for sensitive data
Use secrets for sensitive data
Don’t store API keys in Add
docker-compose.yml. Use Docker secrets or environment files:docker-compose.yml
.env to .gitignore.Run as non-root user
Run as non-root user
Add a non-root user to the Dockerfile:Update volume permissions:
Restrict network access
Restrict network access
Use Docker networks to isolate the container:
Enable workspace restrictions
Enable workspace restrictions
In
config.json, enable workspace sandboxing:Production Checklist
- Configure proper resource limits
- Enable health checks
- Set up log rotation (Docker handles this by default)
- Use secrets management for API keys
- Enable workspace restrictions
- Configure automatic restarts (
restart: unless-stopped) - Set up monitoring and alerts
- Back up
~/.nanobotdirectory regularly - Use specific image tags instead of
latest - Test container recovery after crashes
Next Steps
Linux Service
Deploy as a systemd service for native Linux installations
Multiple Instances
Run multiple isolated nanobot instances
Channel Setup
Configure Telegram, Discord, WhatsApp, and more
Configuration
Complete configuration reference