Skip to content

Redis - Environment

Setting up a Redis environment is straightforward. For modern development, using containerization with Docker is the recommended approach for its consistency and isolation.

Docker provides a clean, portable, and reproducible environment. First, ensure you have Docker installed on your system.

This command downloads the latest official Redis image and starts a container named my-redis-instance.

# Pull the latest Redis image and run it
docker run --name my-redis-instance -p 6379:6379 -d redis

Your Redis server is now running and accessible on localhost:6379.

For projects, using a docker-compose.yml file is best practice. Create a file with this content:

version: '3.8'
services:
redis:
image: 'redis:latest'
container_name: project-redis
ports:
- '6379:6379'
volumes:
- ./redis-data:/data # Optional: Persists data on your host machine

Then, run docker-compose up -d in the same directory to start the service.

You can also install Redis directly on your operating system.

  • On Ubuntu/Debian: $ sudo apt update && sudo apt install redis-server
  • On macOS (using Homebrew): $ brew install redis
  • On Windows (using WSL2): Install a Linux distribution (like Ubuntu) and follow its instructions.

For other systems or to compile from source, refer to the official documentation at redis.io/download.

Regardless of the installation method, you can verify that Redis is running using redis-cli, the command-line interface.

$ redis-cli
127.0.0.1:6379>

At the prompt, type the PING command. The server should reply with PONG.

127.0.0.1:6379> ping
PONG

This confirms your Redis server is up and running correctly.

While redis-cli is powerful, a graphical user interface can be very helpful for visualizing data.

  • RedisInsight: The official free GUI from Redis. It provides powerful features for querying, profiling, and managing your Redis data. Download it from redis.com/redis-enterprise/redis-insight/.
  • TablePlus: A popular, modern database client that supports Redis along with many other databases.
  • Other alternatives exist for different platforms and preferences.

For production, it is highly recommended to use a managed Redis service from a cloud provider, such as AWS ElastiCache, Google Cloud Memorystore, or Azure Cache for Redis. These services handle setup, scaling, high availability, and maintenance for you.