Docker image for Redis with support for authentication and replication
Redis is an open-source, networked, in-memory, key-value data store with optional durability. It is written in ANSI C. The development of Redis has been sponsored by Pivotal since May 2013; before that, it was sponsored by VMware. According to the monthly ranking by DB-Engines.com, Redis is the most popular key-value store. The name Redis means REmote DIctionary Server.
$ docker run --name some-redis -d maestrano/redis
This image includes EXPOSE 6379
(the redis port), so standard container linking will make it automatically available to the linked containers (as the following examples illustrate).
$ docker run --name some-redis -d maestrano/redis redis-server --appendonly yes
If persistence is enabled, data is stored in the VOLUME /data
, which can be used with --volumes-from some-volume-container
or -v /docker/host/dir:/data
(see docs.docker volumes).
For more about Redis Persistence, see http://redis.io/topics/persistence.
$ docker run --name some-app --link some-redis:maestrano/redis -d application-that-uses-redis
$ docker run -it --link some-redis:redis --rm maestrano/redis redis-cli -h redis -p 6379
Specify authentication password for connecting to redis (set requirepass
directive in redis conf). Setting this environment variable will require clients to issue AUTH before processing any other commands.
Warning: since Redis is pretty fast an outside user can try up to 150k passwords per second against a good box. This means that you should use a very strong password otherwise it will be very easy to break.
Specify a redis master to replicate data from. Format must follow :. If a REDIS_PASS
is specified then this pass will be used to set the master-slave replication.
Example
# Container setup
HOST_PUB_IP=`ifconfig | grep en0 -A 5 | grep "inet " | cut -d' ' -f2`
PORT_NODE_1=33001
PORT_NODE_2=33002
docker run -d -p $PORT_NODE_1:6379 \
-e SELF_HOST=$HOST_PUB_IP \
-e SELF_PORT=$PORT_NODE_1 \
-e REDIS_MASTER=$HOST_PUB_IP:$PORT_NODE_1 \
-e REDIS_PASS=somepass \
--name r1 \
maestrano/redis
docker run -d -p $PORT_NODE_2:6379 \
-e SELF_HOST=$HOST_PUB_IP \
-e SELF_PORT=$PORT_NODE_2 \
-e REDIS_MASTER=$HOST_PUB_IP:$PORT_NODE_1 \
-e REDIS_PASS=somepass \
--name r2 \
maestrano/redis
# Set key
while true; do
key=$(openssl rand -base64 16)
redis-cli -h $HOST_PUB_IP -p $PORT_NODE_1 -a somepass set $key somevalue
done
# Count keys
redis-cli -h $HOST_PUB_IP -p $PORT_NODE_1 -a somepass info | grep 'db0' | cut -d',' -f1 | cut -d'=' -f2
redis-cli -h $HOST_PUB_IP -p $PORT_NODE_2 -a somepass info | grep 'db0' | cut -d',' -f1 | cut -d'=' -f2
View license information for the software contained in this image.
This image is officially supported on Docker version 1.11.2.
Support for older versions (down to 1.6) is provided on a best-effort basis.
Please see the Docker installation documentation for details on how to upgrade your Docker daemon.