Skip to content

andrebhas/redis-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Redis Docker Setup

Docker Redis Alpine Linux

A lightweight, persistent Redis setup using Docker Compose with Alpine Linux image for optimal performance and minimal resource usage.

✨ Features

  • 🐳 Lightweight: Uses Redis Alpine image for minimal footprint
  • 💾 Persistent Data: Automatic data persistence with append-only file
  • 🔄 Auto-restart: Services restart automatically unless manually stopped
  • 🛠️ Easy Management: Makefile with comprehensive commands
  • 📦 One-click Setup: Automated setup script
  • 🔍 Monitoring: Built-in logging and status checking

📋 Prerequisites

  • Docker (latest version recommended)
  • Docker Compose (or Docker Compose V2)

🚀 Quick Start

Option 1: Automated Setup (Recommended)

./setup.sh

Option 2: Manual Setup

# Make setup script executable (first time only)
chmod +x setup.sh

# Run setup
./setup.sh

📖 Usage

Basic Commands

# Start Redis
make up

# Stop Redis
make down

# View logs
make logs

# Check status
make status

# Restart Redis
make restart

Advanced Commands

# Open shell in Redis container
make shell

# Backup data
make backup

# Restore from backup
make restore

# Clean up everything (removes data!)
make clean

Direct Docker Compose

# Start services
docker-compose up -d

# Stop services
docker-compose down

# View logs
docker-compose logs -f redis

🔧 Configuration

Environment Variables

You can customize Redis behavior by modifying the docker-compose.yml:

command: redis-server --appendonly yes --dir /data --maxmemory 256mb --maxmemory-policy allkeys-lru

Data Persistence

  • Data is stored in ./data directory
  • Append-only file (AOF) is enabled for durability
  • Survives container restarts and recreations

📊 Monitoring

Check Redis Status

# From host
redis-cli ping

# From container
make shell
redis-cli ping

View Logs

make logs

🔒 Security Notes

  • Redis is running without password by default
  • For production use, consider adding authentication
  • Exposed on port 6379 (change in docker-compose.yml if needed)

🆘 Troubleshooting

Common Issues

  1. Port 6379 already in use

    # Find process using port
    lsof -i :6379
    # Or change port in docker-compose.yml
  2. Permission denied on data directory

    sudo chown -R $USER:$USER data
  3. Docker not running

    sudo systemctl start docker

Reset Everything

make clean
rm -rf data
./setup.sh

📁 Project Structure

.
├── docker-compose.yml    # Docker Compose configuration
├── Makefile             # Management commands
├── setup.sh             # Automated setup script
├── data/                # Persistent Redis data (created automatically)
└── README.md            # This file

🤝 Contributing

Feel free to submit issues and enhancement requests!

📄 License

This project is open source and available under the MIT License.


Happy Redis-ing! 🎉

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors