Redis sentinel docker image / Dockerfile
Asked Answered
P

2

9

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
Plasterboard answered 18/9, 2014 at 14:1 Comment(0)
P
12

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/

Plasterboard answered 19/9, 2014 at 16:7 Comment(6)
Hey, Joshula - I've incorporated your docker file into a script that sets up a master/slave cluster with sentinel configuration. Great if you could have a look at it and feedback?Auerbach
Hi Mark, that looks pretty good, a few notes to just keep in mind as you move forward: the announce-ip config was added in version +2.8.15 (so just be aware of versions). Please ensure that in a production environment (where the sentinels are all on different physical machines) that 'announce-ip' is referencing the IP of the physical host machine. Also, I (and some other folks have confirmed) performance issues when running Redis in a container -- specifically around the extra networking layers/bridges that Docker introduces...Plasterboard
So, I've decided to install/run Redis (in production) on a physical machine (as Antirez and Mattsta said in above posts, Redis and Sentinel have not yet been fully designed/optimized to run in a Docker-like environment.Plasterboard
Thanks for the feedback - I am running this purely for developing against but noted. Its funny as there are a lot of Redis containers out there!Auerbach
Yep, I know. I've learned (the hard way) that you're kinda "on your own" when it comes to putting a production system together for a particular use-case. A lot of what's "out there" is not production friendly or ready.Plasterboard
Any chance you could post the Dockerfile for this? Do you have GitHub repo this is stored on?Adenoid
X
1

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.

Xantho answered 24/11, 2020 at 8:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.