Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/dokploy/dokploy/llms.txt

Use this file to discover all available pages before exploring further.

Redis is an open-source, in-memory data structure store used as a database, cache, message broker, and streaming engine. It’s known for exceptional performance and versatility.

Creating a Redis Database

1

Navigate to Databases

In your Dokploy dashboard, select your environment and click Add Database > Redis.
2

Configure Basic Settings

Provide the required information:
  • Name: Display name for your Redis instance
  • App Name: Internal DNS name (e.g., redis-cache)
  • Description: Optional notes about usage
  • Docker Image: Redis version (default: redis:8)
3

Set Password

Configure Redis authentication:
Password: <strong-password>
Redis uses a single password for authentication. All clients must provide this password.
4

Deploy

Click Create to deploy. Dokploy will:
  • Pull the Redis Docker image
  • Create a volume at /data for persistence
  • Start Redis with password authentication

Connection Information

Applications in the same environment connect via internal DNS:
Host: <app-name>  # e.g., redis-cache
Port: 6379
Password: <your-password>
Connection String Examples:
# Standard Redis URL
redis://:password@redis-cache:6379

# With database number (0-15)
redis://:password@redis-cache:6379/0

# Redis CLI
redis-cli -h redis-cache -p 6379 -a password

Configuration

Environment Variables

Customize Redis behavior:
# Memory management
REDIS_MAXMEMORY=512mb
REDIS_MAXMEMORY_POLICY=allkeys-lru

# Persistence
REDIS_SAVE="900 1 300 10 60 10000"  # RDB snapshots
REDIS_APPENDONLY=yes                  # AOF persistence
REDIS_APPENDFSYNC=everysec            # AOF sync frequency

# Performance
REDIS_DATABASES=16
REDIS_TCP_BACKLOG=511
REDIS_TIMEOUT=300
REDIS_TCP_KEEPALIVE=300

# Slowlog
REDIS_SLOWLOG_LOG_SLOWER_THAN=10000  # microseconds
REDIS_SLOWLOG_MAX_LEN=128

# Timezone
TZ=America/New_York

Resource Allocation

Redis resource recommendations:
Use CaseMemory ReservationMemory LimitCPU ReservationCPU Limit
Session Store128MB256MB0.10.25
Cache (Small)256MB512MB0.250.5
Cache (Medium)512MB1GB0.51.0
Cache (Large)1GB2GB1.02.0
Message Queue512MB2GB0.51.0
Redis stores all data in memory. Set memory limits appropriately based on your dataset size.

Docker Image Versions

Redis version options:
# Latest versions
redis:8           # Default (Redis 7.x or 8.x if available)
redis:7           # Redis 7.x
redis:7.2         # Redis 7.2.x
redis:6           # Redis 6.x

# Alpine variants (smaller size)
redis:7-alpine
redis:6-alpine

# Specific versions
redis:7.2.4
redis:6.2.14

Database Operations

Lifecycle Management

Control Redis availability:Start:
  • Status: done
  • Accepts connections
  • Loads persisted data
Stop:
  • Status: idle
  • Saves data to disk
  • Closes all connections
  • No resource usage

Volume Management

Redis stores persistent data in a Docker volume:
Volume Name: {appName}-data
Mount Path: /data
Volume contents:
  • RDB snapshots (dump.rdb)
  • AOF files (appendonly.aof)
  • Configuration backups
Redis persistence is optional. Configure RDB and/or AOF based on your durability requirements.

Persistence Options

RDB (Redis Database)

Point-in-time snapshots:
# Save frequency: "seconds changes"
REDIS_SAVE="900 1 300 10 60 10000"

# Manual save commands
SAVE      # Blocking save
BGSAVE    # Background save
Pros:
  • Compact single file
  • Fast restart
  • Good for backups
Cons:
  • Data loss between snapshots
  • Fork may use 2x memory

AOF (Append Only File)

Logs every write operation:
REDIS_APPENDONLY=yes
REDIS_APPENDFSYNC=everysec  # always, everysec, no
Pros:
  • Minimal data loss
  • Append-only (safer)
  • Auto-rewrite when large
Cons:
  • Larger file size
  • Slower restart
  • Small performance impact

Recommendation

For production, use both:
# Enable both RDB and AOF
REDIS_SAVE="900 1 300 10"
REDIS_APPENDONLY=yes
REDIS_APPENDFSYNC=everysec

Advanced Configuration

Custom Startup Options

Command:
redis-server
Arguments:
--maxmemory 512mb
--maxmemory-policy allkeys-lru
--appendonly yes
--appendfsync everysec
--save 900 1
--save 300 10

Health Check Configuration

{
  "test": ["CMD-SHELL", "redis-cli ping | grep PONG"],
  "interval": 30000000000,
  "timeout": 5000000000,
  "retries": 3
}

Restart Policy

{
  "condition": "on-failure",
  "delay": 5000000000,
  "maxAttempts": 3
}

Common Use Cases

Store user sessions:
Docker Image: redis:7-alpine
Memory Limit: 256MB
CPU Limit: 0.25

# Environment
REDIS_MAXMEMORY=200mb
REDIS_MAXMEMORY_POLICY=allkeys-lru
REDIS_SAVE=""
REDIS_APPENDONLY=no
No persistence needed - sessions can be recreated.

Memory Policies

Configure eviction when memory limit is reached:
PolicyDescriptionUse Case
noevictionReturn errors when memory fullMessage queues
allkeys-lruEvict least recently used keysGeneral cache
allkeys-lfuEvict least frequently used keysFrequency-based cache
volatile-lruEvict LRU keys with expirationMixed workload
volatile-ttlEvict keys with shortest TTLTime-sensitive data
allkeys-randomEvict random keysUniform importance

Monitoring and Logs

View Redis logs:
  1. Open your Redis service
  2. Navigate to Logs tab
  3. Monitor operations and errors
Common log patterns:
# Successful startup
Redis server started, Redis version 7.2.4
Server initialized
Ready to accept connections

# Persistence
Background saving started by pid 123
DB saved on disk

# Memory
Used memory: 45.67M
Memory usage: 45.67M (5% of limit)

Redis CLI Commands

Useful commands for administration:
# Connection test
PING
# Response: PONG

# Authentication
AUTH password

# Information
INFO
INFO memory
INFO stats

# Memory usage
MEMORY USAGE key
MEMORY STATS

# Slow log
SLOWLOG GET 10
SLOWLOG RESET

# Key operations
KEYS pattern       # Don't use in production!
SCAN 0 MATCH *     # Use SCAN instead
DBSIZE

# Persistence
SAVE               # Blocking save
BGSAVE             # Background save
LASTSAVE           # Last save timestamp
BGREWRITEAOF       # Rewrite AOF file

# Performance
MONITOR            # Watch commands in real-time
CLIENT LIST        # Connected clients

Troubleshooting

Connection troubleshooting:
  1. Verify host: Use app name internally
  2. Check port: 6379 internal, custom external
  3. Test password: Ensure correct password
  4. Database status: Must be done
Test connection:
# Internal
redis-cli -h redis-cache -p 6379 -a password PING

# External
redis-cli -h your-server.com -p 6380 -a password PING
Redis hitting memory limits:
  1. Check current usage:
    redis-cli INFO memory
    
  2. Solutions:
    • Increase memory limit
    • Enable eviction:
      REDIS_MAXMEMORY_POLICY=allkeys-lru
      
    • Set expiration on keys:
      EXPIRE key seconds
      
    • Clear unused data:
      FLUSHDB  # Be careful!
      
Performance optimization:
  1. Check slow log:
    SLOWLOG GET 10
    
  2. Avoid KEYS command: Use SCAN instead
  3. Optimize data structures:
    • Use hashes for objects
    • Use sets for unique items
    • Use sorted sets for rankings
  4. Enable pipelining in your client
  5. Increase memory if heavily evicting
Persistence not configured:
  1. Enable RDB snapshots:
    REDIS_SAVE="900 1 300 10"
    
  2. Enable AOF:
    REDIS_APPENDONLY=yes
    REDIS_APPENDFSYNC=everysec
    
  3. Manual save:
    redis-cli BGSAVE
    
  4. Verify persistence files exist in volume

Best Practices

Security

  1. Strong password: Use complex passwords
  2. Rename dangerous commands:
    --rename-command FLUSHDB ""
    --rename-command FLUSHALL ""
    --rename-command CONFIG "CONFIG_xyz123"
    
  3. Limit external access: Only expose when necessary
  4. Use firewall rules: Restrict IP access

Performance

  1. Set expiration: Use TTL on temporary data
  2. Choose right data structures: Optimize for your use case
  3. Use pipelining: Batch commands together
  4. Monitor memory: Track usage and evictions
  5. Avoid blocking commands: Use SCAN not KEYS

Reliability

  1. Configure persistence: Based on durability needs
  2. Monitor logs: Check for warnings
  3. Set memory limits: Prevent OOM
  4. Regular backups: Copy RDB/AOF files
  5. Test recovery: Practice restore procedures

Redis Commander

Use Redis Commander for web-based management:
# Run as Docker container
docker run -d \
  --name redis-commander \
  -p 8081:8081 \
  -e REDIS_HOSTS=local:redis-cache:6379:0:password \
  rediscommander/redis-commander
Access at http://localhost:8081

Next Steps

Database Backups

Redis doesn’t use standard backups - configure persistence instead

PostgreSQL

Deploy a PostgreSQL database