bashbeginner
Redis Docker Setup with Persistence
Docker Compose for Redis with persistence, password auth, memory limits, and a health check.
bashPress ⌘/Ctrl + Shift + C to copy
# docker-compose.redis.yml
version: '3.8'
services:
redis:
image: redis:7-alpine
command: redis-server /usr/local/etc/redis/redis.conf
ports:
- '6379:6379'
volumes:
- redis-data:/data
- ./redis.conf:/usr/local/etc/redis/redis.conf:ro
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 10s
timeout: 5s
retries: 3
restart: unless-stopped
deploy:
resources:
limits:
memory: 256M
volumes:
redis-data:
# redis.conf
# requirepass your_strong_password
# maxmemory 200mb
# maxmemory-policy allkeys-lru
# appendonly yes
# appendfsync everysec
# save 900 1
# save 300 10Use Cases
- Local Redis instance for development
- Session store for web applications
- Caching layer with data persistence
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashbeginner
Docker Volume Management Commands
Essential Docker volume commands for data persistence, backup, migration, and cleanup.
Best for: Persisting database data across container restarts
#docker#volumes
typescriptadvanced
Redis Cache Get/Set Helper
Type-safe Redis cache wrapper with automatic JSON serialization, TTL support, and cache-aside pattern.
Best for: Database query caching
#redis#cache
bashintermediate
Docker Compose Multi-Service Setup
Docker Compose configuration for a Node.js app with PostgreSQL, Redis, and Nginx reverse proxy.
Best for: Local development environment with multiple services
#docker#compose
bashbeginner
PostgreSQL Docker Setup with Init Script
Docker Compose for PostgreSQL with volume persistence, init scripts, and connection pooling.
Best for: Local PostgreSQL for development
#postgres#docker