Creating a Redis Database
To create a Redis database in Dokploy:- Navigate to your project
- Select the environment
- Click “Add Service” and select “Redis”
- Configure the database settings
Basic Configuration
- Name - A friendly name for your Redis instance
- App Name - The Docker service name (used for internal DNS)
- Description - Optional description
- Docker Image - Default:
redis:latest(recommended:redis:7-alpineorredis:7)
Database Credentials
- Database Password - Password for Redis authentication (optional but recommended)
The password is automatically configured via the
REDIS_PASSWORD environment variable and passed as a command argument: redis-server --requirepass [password]Advanced Settings
- External Port - Optional port to expose Redis externally (default internal port: 6379)
- Command - Override the default container command
- Args - Additional arguments to pass to Redis server
- Environment Variables - Additional custom environment variables
Connection Strings
Internal Connection (from other services)
With Password
Without Password (not recommended)
External Connection
If you’ve configured an external port (e.g., 6380):Connection String Formats
- Standard URI
- redis-cli Command
- Node.js (ioredis)
- Python (redis-py)
- Go (go-redis)
Environment Variables
Redis containers support these environment variables:| Variable | Description | Required |
|---|---|---|
REDIS_PASSWORD | Authentication password | Recommended |
Dokploy automatically configures Redis with the password using the
--requirepass argument.Data Persistence
Redis data is stored in a Docker volume mounted at:- Mount Path:
/data - Volume Name:
{appName}-data
Persistence Modes
Redis supports two persistence modes:- RDB (Redis Database) - Point-in-time snapshots
- AOF (Append Only File) - Logs every write operation
Resource Configuration
Configure resource limits for your Redis instance:Operations
Starting the Database
Click the “Start” button in the Dokploy UI or use the API:Stopping the Database
Click the “Stop” button or use the API:Reloading the Database
Reload applies configuration changes by stopping and starting the service:Rebuilding the Database
Accessing Redis CLI
To access the Redis CLI in the running container:Common Redis Commands
Configuration Options
Add these as arguments in the “Args” field:Eviction Policies
When Redis reaches max memory, it can evict keys based on different policies:| Policy | Description |
|---|---|
noeviction | Return errors when memory limit is reached |
allkeys-lru | Remove least recently used keys |
allkeys-lfu | Remove least frequently used keys |
volatile-lru | Remove LRU keys with expire set |
volatile-lfu | Remove LFU keys with expire set |
volatile-ttl | Remove keys with shortest TTL |
volatile-random | Remove random keys with expire set |
allkeys-random | Remove random keys |
Use Cases
1. Caching
2. Session Storage
3. Rate Limiting
4. Message Queue
5. Pub/Sub
Monitoring and Performance
Key Metrics to Monitor
Slow Query Log
Backups
While Redis is typically used for caching and doesn’t need backups, Dokploy supports Redis backups if persistence is enabled.Manual Backup
Troubleshooting
Connection Refused
- Verify the service is running in Dokploy UI
- Check the service name matches your
appName - Ensure your application is in the same Docker network
Authentication Failed
- Verify password in the database settings
- Check if password is correctly set in connection string
- Use
-a passwordflag with redis-cli
Out of Memory
- Check current memory usage:
INFO memory - Set
maxmemorylimit - Configure eviction policy
- Increase memory limits in resource configuration
Performance Issues
- Check slow query log:
SLOWLOG GET - Monitor key sizes: Large keys can slow Redis
- Use pipelining for multiple operations
- Enable AOF if needed, but be aware of performance impact
- Consider using Redis Cluster for large datasets
Best Practices
- Use Specific Versions - Pin to specific Redis versions (e.g.,
redis:7.2.4-alpine) instead oflatest - Always Use Passwords - Never run Redis without authentication in production
- Set Max Memory - Always configure
maxmemoryto prevent OOM issues - Choose Eviction Policy - Select appropriate eviction policy for your use case
- Don’t Expose Publicly - Keep Redis on internal networks
- Monitor Memory - Watch memory usage and key counts
- Use Connection Pooling - Reuse connections in your applications
- Enable Persistence - Use AOF or RDB if data durability is important
- Avoid Large Keys - Keep individual keys small (< 1MB recommended)
- Use Key Expiration - Set TTL on keys to prevent unbounded growth
Redis vs Other Caches
| Feature | Redis | Memcached | In-Memory |
|---|---|---|---|
| Data Types | Rich | Simple | Varies |
| Persistence | Yes | No | No |
| Replication | Yes | No | No |
| Pub/Sub | Yes | No | No |
| Transactions | Yes | No | Varies |
| Lua Scripting | Yes | No | No |
| Performance | Excellent | Excellent | Best |
Next Steps
Backups
Configure Redis persistence and backups
Overview
Learn about other database options