Docker Community Forums

Share and learn in the Docker community.

High Avail Redis (need Sentinel Dockerfile)


(Josh Abrams) #1

I’m looking to deploy high availability Redis on a coreOS cluster, and I need a Redis Sentinel docker image (i.e. Dockerfile) that works. I’ve gathered enough information/expertise to create one (I think)… but my limited knowledge/experience with advanced networking is the only thing keeping me from building and sharing it.

Can someone who is an expert here help me developing a Redis Sentinel Dockerfile (none exist right now)? The Redis/Docker community would really benefit from this.

Here’s the broader issue, context, and I think the solution is right here specifically: https://github.com/antirez/redis/pull/1908#issuecomment-54380876

Here’s the Dockerfile I’ve been using… but if you read the thread above, you’ll see my comments (joshula)… it lacks the Networking fixes that mattsta is talking about. Note that because I’m using this on coreOS, any config settings in sentinel.conf are being set at run-time via the command line (hence ENTRYPOINT).

Pull base image.

FROM dockerfile/ubuntu:latest

Install Redis.

RUN
cd /tmp &&
wget http://download.redis.io/redis-stable.tar.gz &&
tar xvzf redis-stable.tar.gz &&
cd redis-stable &&
make &&
make install &&
cp -f src/redis-sentinel /usr/local/bin &&
mkdir -p /etc/redis &&
cp -f .conf /etc/redis &&
rm -rf /tmp/redis-stable
&&
sed -i ‘s/^(bind .)$/# \1/’ /etc/redis/redis.conf &&
sed -i 's/^(daemonize .
)$/# \1/’ /etc/redis/redis.conf &&
sed -i ‘s/^(dir .)$/# \1\ndir /data/’ /etc/redis/redis.conf &&
sed -i 's/^(logfile .
)$/# \1/’ /etc/redis/redis.conf

Define mountable directories.

VOLUME ["/data"]

Define working directory.

WORKDIR /data

Expose ports.

EXPOSE 26379

Define default command.

ENTRYPOINT redis-sentinel /etc/redis/sentinel.conf


(Josh Abrams) #2

After a ton of work, I ended up figuring this out. Here’s to making it simple for anyone else who wants to deploy a highly available redis instance via Docker:

https://registry.hub.docker.com/u/joshula/redis-sentinel/


(Junius) #3

Sentinel is only required for 1 master + slaves. Would be better to switch to use Redis Cluster. Redis Cluster handles failure automatically without Sentinel.