Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis sentinel docker image / Dockerfile

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 and context: https://github.com/antirez/redis/pull/1908

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
like image 995
joshula Avatar asked Sep 18 '14 14:09

joshula


2 Answers

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/

like image 161
joshula Avatar answered Oct 13 '22 10:10

joshula


There is no need for a custom sentinel image, or messing with the network. See my redis-ha-learning project using Spring Data Redis, bitnami/redis and bitnami/redis-sentinel images. The Docker Compose file is here. My code auto detects the sentinels based on the Docker Compose container names.

like image 35
Abhijit Sarkar Avatar answered Oct 13 '22 12:10

Abhijit Sarkar