How to Install & Setup Redis for Dokku

Caching Caching
DevOps DevOps
Dokku Dokku
PaaS PaaS
Redis Redis

Redis is a free and open-source in-memory data store which can be used as cache or in same cases even a database. Redis is super simple to install if you manage your applications with your own Dokku PaaS (Platform as a Service).

In today's tutorial I will show you how we can install and setup Redis for Dokku.

1. Install Dokku's Redis Plugin

We start of by installing Dokku's Redis plugin. With this plugin we can easily manage and connect Redis to any application on our server.

sudo dokku plugin:install https://github.com/dokku/dokku-redis.git redis

The plugin requires an installation of dokku 0.12.x+ and docker 1.8.x.

2. Create a Redis Service

When we have installed the redis-dokku plugin we can go ahead and create our first Redis Service.

dokku redis:create service-name

3. Link your Redis Service with your Application

When you have created your Redis Service it is time to link it with your application container. We must do this to make Redis aware to what application to connect to, as you can have multiple application running on a dokku instance.

dokku redis:link service-name app-name

4. Add Redis REDIS_URL to Production Settings

Add the new REDIS_URL to your .env variables in your local development project and modify your production settings accordingly. This will of course vary depending on what application you are building and with what language, framework or tool you are using.

In django for example I use "django-environ" to handle .env and spcify my production CACHES settings as such.


CACHES = {
    'default': env.cache('REDIS_URL')
}

I have barley scratched the surface of what's possible with the dokku-redis plugin in this tutorial, Although this is all you have to do to get Redis up and running with Dokku. 

I urge you to further explore the commmands below to get a better understanding of what's possible with this Dokku plugin.

Redis Dokku Commands

redis:app-links                               # list all redis service links for a given app
redis:backup   [--use-iam]   # creates a backup of the redis service to an existing s3 bucket
redis:backup-auth       # sets up authentication for backups on the redis service
redis:backup-deauth                       # removes backup authentication for the redis service
redis:backup-schedule    [--use-iam] # schedules a backup of the redis service
redis:backup-schedule-cat                 # cat the contents of the configured backup cronfile for the service
redis:backup-set-encryption   # sets encryption for all future backups of redis service
redis:backup-unschedule                   # unschedules the backup of the redis service
redis:backup-unset-encryption             # unsets encryption for future backups of the redis service
redis:clone   [--clone-flags...] # create container  then copy data from  into 
redis:connect                             # connect to the service via the redis connection tool
redis:create  [--create-flags...]         # create a redis service
redis:destroy  [-f|--force]               # delete the redis service/data/container if there are no links left
redis:enter                               # enter or run a command in a running redis service container
redis:exists                              # check if the redis service exists
redis:export                              # export a dump of the redis service database
redis:expose                    # expose a redis service on custom port if provided (random port otherwise)
redis:import                              # import a dump into the redis service database
redis:info  [--single-info-flag]          # print the service information
redis:link   [--link-flags...]       # link the redis service to the app
redis:linked                         # check if the redis service is linked to an app
redis:links                               # list all apps linked to the redis service
redis:list                                         # list all redis services
redis:logs  [-t|--tail]                   # print the most recent log(s) for this service
redis:promote                        # promote service  as REDIS_URL in 
redis:restart                             # graceful shutdown and restart of the redis service container
redis:start                               # start a previously stopped redis service
redis:stop                                # stop a running redis service
redis:unexpose                            # unexpose a previously exposed redis service
redis:unlink                         # unlink the redis service from the app
redis:upgrade  [--upgrade-flags...]       # upgrade service  to the specified versions

Did You Enjoy the Tutorial?

Consider sending some love to Freddie the creator.

Comments (0)

You need to be logged in to comment..

Topics Mentioned in this Tutorial

Caching
3
0
0
Caching is a process in computing that stores data for future faster reference. The data stored in a cache yield faster result by storing a copy of an original query. Caching can be applied to both software and hardware....
DevOps
6
0
24
DevOps stands for Development Operations and is a set of practices used to improve software development and information-technology operations. Part of the DevOps responsibility is to setup servers, integrate continuous integration and continuous deployment (CI/CD) to maintain and improve the development life cycle....
Dokku
7
0
0
With Dokku web developers can build their own PaaS (Platform-as-a-Service) with help of Docker and open sourced Heroku build packs. Dokku Installs on any hardware and drastically lowers your cost as Dokku is both free and open source. The dokku setup process is extremly simple and only takes a matter of minutes to complete. Once Dokku is installed and your PaaS is ready for use you can push your local development project using Git. Which builds your applicaion using Heroku buildpacks that runs in isolated Docker containers. As a result, you can run your own PaaS on the cloud provider of your c...
PaaS
4
0
0
PaaS stands for Platform-as-a-Service is a complete development and deployment environment in the cloud. With a PaaS you developers can deliver anything form simple cloud app to sophisticated enterprise applications. A PaaS toolset includes development tools, database management and business analytics. It also includes all of the features included in an IaaS (Infrastructure-as-a-Service) servers and storage, networking security and data center.   ...
Redis
3
0
1
Redis is an open source 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....