Skip to content

Redis Resources

This directory contains resources for working with Redis in Docker, including guides and configuration files.

Files in this Directory

  • make-a-redis-cluster.md: Detailed guide on setting up a Redis cluster with Docker
  • redis-cluster/: Directory containing configuration files for Redis cluster setup

Quick Start

To run a single Redis instance for development:

bash
docker run -d --name redis -p 6379:6379 redis:7.0-alpine

Or create a simple docker-compose.yml file:

yaml
version: "3.8"

services:
  redis:
    image: redis:7.0-alpine
    container_name: redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data

volumes:
  redis_data:

And run it with:

bash
docker-compose up -d

Testing Your Redis Instance

Using Redis CLI

bash
# Connect to Redis CLI
docker exec -it redis redis-cli

# Set a key
> SET test_key "Hello, Redis!"

# Get a key
> GET test_key

# List all keys
> KEYS *

# Exit the CLI
> exit

Using Redis Commander (Web UI)

For a web-based interface to Redis:

bash
docker run --rm -it --network host rediscommander/redis-commander --redis-host localhost

Access it at http://localhost:8081

Monitoring Redis

Viewing Logs

bash
# View container logs
docker logs redis

# Follow logs in real-time
docker logs -f redis

Redis Information and Statistics

bash
# Get statistics about the Redis server
docker exec -it redis redis-cli info

# Check memory usage
docker exec -it redis redis-cli info memory

# Monitor all Redis commands in real-time
docker exec -it redis redis-cli monitor

Setting Up a Cluster

For production or testing high availability features, you may want to set up a Redis cluster. See the Redis Clustering Guide for detailed instructions.