Run Redis Stack on Docker
How to install Redis Stack using Docker
To get started with Redis Stack using Docker, you first need to select a Docker image:
-
redis/redis-stackcontains both Redis Stack server and RedisInsight. This container is best for local development because you can use the embedded RedisInsight to visualize your data. -
redis/redis-stack-serverprovides Redis Stack server only. This container is best for production deployment.
Getting started
redis/redis-stack-server
To start Redis Stack server using the redis-stack-server image, run the following command in your terminal:
docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latestredis/redis-stack
To start a Redis Stack container using the redis-stack image, run the following command in your terminal:
docker run -d --name redis-stack -p 6379:6379 -p 8001:8001 redis/redis-stack:latestThe docker run command above also exposes RedisInsight on port 8001. You can use RedisInsight by pointing your browser to localhost:8001.
Connect with redis-cli
You can then connect to the server using redis-cli, just as you connect to any Redis instance.
If you don’t have redis-cli installed locally, you can run it from the Docker container:
$ docker exec -it redis-stack redis-cliConfiguration
Persistence in Docker
To mount directories or files to your Docker container, specify -v to configure a local volume. This command stores all data in the local directory local-data:
$ docker run -v /local-data/:/data redis/redis-stack:latestPorts
If you want to expose Redis Stack server or RedisInsight on a different port, update the left hand of portion of the -p argument. This command exposes Redis Stack server on port 10001 and RedisInsight on port 13333:
$ docker run -p 10001:6379 -p 13333:8001 redis/redis-stack:latestConfig files
By default, the Redis Stack Docker containers use internal configuration files for Redis. To start Redis with local configuration file, you can use the -v volume options:
$ docker run -v `pwd`/local-redis-stack.conf:/redis-stack.conf -p 6379:6379 -p 8001:8001 redis/redis-stack:latestEnvironment variables
To pass in arbitrary configuration changes, you can set any of these environment variables:
-
REDIS_ARGS: extra arguments for Redis -
REDISEARCH_ARGS: arguments for the search and query features (RediSearch) -
REDISJSON_ARGS: arguments for JSON (RedisJSON) -
REDISTIMESERIES_ARGS: arguments for time series (RedisTimeSeries) -
REDISBLOOM_ARGS: arguments for the probabilistic data structures (RedisBloom)
For example, here's how to use the REDIS_ARGS environment variable to pass the requirepass directive to Redis:
docker run -e REDIS_ARGS="--requirepass redis-stack" redis/redis-stack:latestAn example of setting Redis persistence:
docker run -e REDIS_ARGS="--save 60 1000 --appendonly yes" redis/redis-stack:latestHere's how to set a retention policy for time series:
docker run -e REDISTIMESERIES_ARGS="RETENTION_POLICY=20" redis/redis-stack:latest