DEV Community

Pradeep Pep
Pradeep Pep

Posted on

Redis for Python - via Docker - No direct WSL

Redis doesn’t officially support native Windows installations anymore. Instead of setting up WSL (Windows Subsystem for Linux), Docker is the easier and more modern way to run Redis on a Windows machine.

Installing Docker Desktop gives you a full environment where you can run Redis (and many other tools) without friction.

🔹 Step 1: Install Docker Desktop
Download and install Docker Desktop from:
https://www.docker.com/products/docker-desktop/

Once installed:
Make sure Docker is running (look for the whale icon in your system tray).
Enable WSL2 integration if prompted during installation.

🔹 Step 2: Pull and Run Redis
Open PowerShell or Command Prompt and run:

docker run --name my-redis -p 6379:6379 -d redis
docker ps

🔹 Step 3: Connect to Redis
docker exec -it my-redis redis-cli
set name "DockerRedis"
get name
ping

Install RedisInsight and connect to:
https://redis.io/insight/
Host: localhost
Port: 6379


To find out whether your Windows PC uses an ARM64 or AMD64 (also called x64) architecture, follow these
from Command Prompt you can run:

C:\Users\pepsara>echo %PROCESSOR_ARCHITECTURE%

AMD64

C:\Users\pepsara>docker version
Client:
Version: 28.0.4
API version: 1.48
Go version: go1.23.7
Git commit: b8034c0
Built: Tue Mar 25 15:07:48 2025
OS/Arch: windows/amd64
Context: desktop-linux

Server: Docker Desktop 4.40.0 (187762)
Engine:
Version: 28.0.4
API version: 1.48 (minimum version 1.24)
Go version: go1.23.7
Git commit: 6430e49
Built: Tue Mar 25 15:07:22 2025
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.26
GitCommit: 753481ec61c7c8955a23d6ff7bc8e4daed455734
runc:
Version: 1.2.5
GitCommit: v1.2.5-0-g59923ef
docker-init:
Version: 0.19.0
GitCommit: de40ad0

C:\Users\pepsara>docker info

✅ Step-by-Step: Use Redis with Python in VS Code
🔧 1. Install Redis client for Python
In your terminal (inside VS Code), run:
pip install redis

🧪 2. Test Redis Connection in Python
Create a new Python file, e.g., redis_test.py, and add the following code:
import redis

Connect to Redis

r = redis.Redis(host='localhost', port=6379, db=0)

Set a key

r.set('mykey', 'Hello Redis!')

Get the key

value = r.get('mykey')
print(value.decode('utf-8')) # Output: Hello Redis!

Then run it: python redis_test.py
You should see: Hello Redis!

Top comments (0)