Can a redis cluster be setup on a mac in a docker container in a way where my host machine can communicate with it?

1,095 views
Skip to first unread message

dka...@pivotal.io

unread,
Jan 13, 2018, 5:18:16 AM1/13/18
to Redis DB
The redis docs say this:  https://redis.io/topics/cluster-tutorial

> In order to make Docker compatible with Redis Cluster you need to use the host networking mode of Docker. Please check the --net=host option in the Docker documentation for more information.

But I found this docker thread that says host mode doesn't expose ports to the host machine: https://forums.docker.com/t/should-docker-run-net-host-work/14215

So, is there a way to setup a redis cluster on my mac where my host machine can communicate with it?  Is there any workaround?  

BTW, it would be super helpful if the redis docs explained WHY I need to use host networking mode.  I feel like that blurb gave me pieces, but didn't really connect them for me.  I don't know what I don't know to learn WHY.  

hva...@gmail.com

unread,
Jan 14, 2018, 1:58:49 AM1/14/18
to Redis DB

BTW, it would be super helpful if the redis docs explained WHY I need to use host networking mode.  I feel like that blurb gave me pieces, but didn't really connect them for me.  I don't know what I don't know to learn WHY.

Let's look at the paragraph where you saw that sentence.  It's found at https://redis.io/topics/cluster-tutorial#redis-cluster-and-docker :

Currently Redis Cluster does not support NATted environments and in general environments where IP addresses or TCP ports are remapped.

Docker uses a technique called port mapping: programs running inside Docker containers may be exposed with a different port compared to the one the program believes to be using. This is useful in order to run multiple containers using the same ports, at the same time, in the same server.

In order to make Docker compatible with Redis Cluster you need to use the host networking mode of Docker. Please check the --net=host option in the Docker documentation for more information.


The part I marked in blue (the first sentence) is where Redis Cluster's requirements are described: no remapped ports.  The part I marked in red (the second sentence) explains the problem with standard Docker containers, with a more explicit description of the problem: "exposed with a different port".  Finally the remainder of the paragraph suggests the Docker configuration to disable the usual port remapping.


That is, it suggests the Docker configuration that worked at the time the documentation page was written.  And some posts in that Docker forum thread indicate the '--net=host' configuration works as expected (and as documented) in every environment besides MacOS.  On top of that, the thread shows the same configuration used to work in MacOS - it's only more recent Docker for Mac versions that --net=host is not sufficient.


You're asking what will work with Docker's current MacOS version, which is a good question.  I'm a DevOps guy, and not a Docker expert or Redis developer, so I don't have experience I can use to dredge the answer out of the Docker documentation. That Docker forum thread has Docker users asking how to make it work, and they couldn't seem to end up with a clear answer either.


The problem is coming from behavior that is peculiar to recent versions of Docker on Mac.  Unless someone in the Redis community has already solved this (and can contribute to this thread), I think your best chances of learning the right configuration are going to come from engaging Docker support.

Reply all
Reply to author
Forward
0 new messages