There are many ways to install Redis, but we will look into Redis Installation using docker-compose which is Operating system agnostic.

Redis is an open-source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes with radius queries, and streams.

Prerequisite

  • You should install Docker on your machine.
  • You should install Docker-Compose on your machine

Create a docker-compose file

touch redis-docker-compose.yml

Put the below components in the file

version: "3.3"
services:
  redis:
    image: redis:6.0.7
    container_name: redis
    restart: always
    volumes:
      - redis_volume_data:/data
    ports:
      - 6379:6379
  redis_insight:
    image: redislabs/redisinsight:1.14.0
    container_name: redis_insight
    restart: always
    ports:
      - 8001:8001
    volumes:
      - redis_insight_volume_data:/db

volumes:
  redis_volume_data:
  redis_insight_volume_data:

The important configurations above are

  • Redis is exposed at port 6379 and the persistent data will be stored in redis_volume_data
  • RedisInsight is exposed at port 8001 and the persistent data will be stored in redis_insight_volume_data

This will start two docker services

  1. Redis Database: This is the actual Redis database server
  2. Redis Insight

With the docker-compose method of Redis, installation you are not actually installing Redis but docker containers are created and Redis data is stored permanently in the docker-volume

Starting the services

You can start the service in foreground mode

docker-compose -f redis-docker-compose.yml up

If you want you can start the services in background mode using

docker-compose -f redis-docker-compose.yml up -d

Access the Redis Graphical User Interface

  • You can access the RedisInsight using http://192.168.0.10:8001
  • You need to accept their privacy settings
  • Then click on Add Redis Database and select Add Database

It will take you to another screen

You need to enter the following data and leave other things blank

  1. Name: Give a meaningful name
  2. Host: Provide the IP Address of the machine where you installed Redis using docker-compose
  3. PORT: Provide the port as 6379

Click on Add Redis Database and then click on the Card where the name given in the above step appears.

You will be taken to the Redis dashboard. You can see all the data related to Redis in that dashboard.

YouTube Channel

Next: Redis Master Slave Replication Using Docker Compose

One thought on “Install redis using docker compose”
  1. Hi,

    Thanks for your tutorial. Do you also have a tutorial which shows how to setup a redis cluster on docker. That would be a real-life example which is required for projects.

    Thanks,
    Parvez

Leave a Reply

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