Post

Starting a Redis Server with a Docker Container

A quick guide to running a Redis server locally in a Docker container on Windows, and testing it with basic redis-cli SET and GET commands.

Starting a Redis Server with a Docker Container

Why Docker Container ?

When using Chocolatey to install Redis in a Windows environment, we often encounter issues with getting the latest version. However, Docker containers running on a Linux environment provide the advantage of working with the most up-to-date Redis systems. Additionally, Docker eliminates the hassle and space allocation required to install a Redis server on a Windows operating system. Instead, it allows us to launch a Redis server effortlessly using a single image.

Starting a Container

To run a Redis server inside a container, we will use the image available at Redis.

In PowerShell, execute the following command:

1
docker run --rm -p 6379:6379 --name rediscontainer -d redis

If the redis image is not available on your Docker platform, it will automatically be pulled from the Docker Hub Registry. Redis, which will be running on port 6379 inside the container, will be accessible externally through port 6379 as well, thanks to the -p 6379:6379 port mapping.

Next, let’s run Redis with the command below:

1
docker exec -it rediscontainer redis-cli

Desktop View Redis Working

As you can see in the image, Redis is now running. Let’s store a message in it:

1
set test "Redis now working"

After receiving the “OK” response, let’s retrieve the message:

1
get test

Desktop View Redis Working

That’s it. As you can see, Redis is working. I hope this is helpful.

If you’d rather run Valkey — the open-source fork mentioned in the licensing section of the previous post — the process is identical, just swap the image: docker run --rm -p 6379:6379 --name valkeycontainer -d valkey/valkey. The redis-cli commands below work exactly the same either way, since Valkey is protocol-compatible with Redis.

Now that you have a running server, the next post covers the actual data types you can store in it — strings, lists, sets, sorted sets, and hashes.

Desktop View Thanks For Reading

This post is licensed under CC BY 4.0 by the author.