To deploy Redis using Docker Desktop on Windows, follow a streamlined process that leverages containerization for consistent, isolated environments.
Prerequisites
Ensure Docker Desktop for Windows is installed and running. Verify its status via the system tray icon or by opening the Docker application. A successful startup confirms the Docker daemon is active and ready to manage containers.
Pulling the Redis Image
Open a terminal (PowerShell or Command Prompt) and execute the following commend to download the official Redis image from Docker Hub:
docker pull redis:latest
This retrieves the most recent stable version of Redis. While not mandatory—Docker auto-pulls if the image is missing—the explicit pull ensures you're aware of the version being used.
Starting the Redis Container
Launch a Redis container with persistent port binding and a custom name:
docker run -d \
--name redis-instance \
-p 6379:6379 \
redis:latest
-druns the container in detached mode (background).--name redis-instanceassigns a human-readable identifier to the container.-p 6379:6379maps port 6379 on the host to the same port inside the container, enabling external connections.redis:latestspecifies the image to use.
Verify the container is running with:
docker ps
You should see an entry for redis-instance with status Up and port mapping 0.0.0.0:6379->6379/tcp.
Accessing the Redis CLI
To interact with the Redis server directly, execute the Redis commmand-line interface inside the running container:
docker exec -it redis-instance redis-cli
docker execruns a command within a running container.-itallocates a pseudo-TTY and keeps stdin open for interactive use.redis-clilaunches the Redis client, providing a prompt where you can issue commands likePING,SET key value, orGET key.
Test connectivity by typing PING and presing Enter. A response of PONG confirms the server is operational.
Optional: Verify External Access
From another terminal or application (e.g., RedisInsight, Python script, or Redis desktop manager), connect to localhost:6379 to confirm the service is accessible outside the container.