Redis, Docker & Raspberry PI

Happy New Year!. Time for the first post of 2020. Have been wanting to write a post on raspberry pi and Redis for some time now. Finally, here it is. I also added docker to the mix of things just to make it interesting. Just to make sure you do need an internet connection.

To get all this going I used a Raspberry Pi 3 Model B Quad Core CPU 1.2 GHz 1 GB RAM, so it is about 4 years old hardware. It uses Raspbian Stretch distribution is also an upgrade from Raspbian Jessie. The upgrade is pretty simple though it took a few hours.

Below is a Raspberry PI which I used for this blog entry. As you can see it has been well-loved 😉

I have divided the entry into three parts

  • Installing docker on Raspberry PI
  • Run a Redis container on Raspberry PI
  • Redis Operations on Raspberry PI
  • Further steps

Install docker on Raspberry PI

To get started just open the terminal session and install docker. You can install it using the command below

curl -sSL https://get.docker.com | sh

It should result in the following output. See Below

Check if the docker service is running or not by using the following command

sudo systemctl status docker

You see a familiar screen below. If you have reached this point.

Run a Redis container on Raspberry PI

With our docker running. Its time to pull a Redis image from hub.docker.com. Below is the command

sudo docker pull redis

Below is the screen once the image has been pulled onto the Raspberry PI.

You can check if the image exists by using the following command.

sudo docker images

It’s time to run the Redis container. We used the following command.

sudo docker run --name cloudwalker-redis -d redis

Redis Docker container is now running successfully on Raspberry PI. This is so exciting!

Redis Operations on Raspberry PI

Time to run some checks if it is actually working. We can now start the redis cli using the following command

sudo docker exec -it cloudwalker-redis redis-cli

We should see something like this below.

Let’s create and retrieve some keys in redis

set testkey "hello world"
get testkey
set rpi "hello from raspberry pi"
get rpi

You see the following responses. We can now run redis through the paces.

Our redis is working!!

Further steps

There are various thing you can do to extend this small experiment. For example

  • Creating a Redis cluster on Raspberry PI(or wait for my post)
  • Mapping volumes out on the host os so that you do not lose any data when container shuts down
  • You can also get to know more about Redis by clicking here.

This brings us to the end of this post. Hope you enjoy this post and is useful for you. Have a great year ahead!

Leave a Reply

Your email address will not be published. Required fields are marked *