Redis Docker - unable to connect to C # client

I am new to docker and redis, I have redis 3.0 running on docker using the following command:

docker run --name redisDev -d redis

It seems to have started just with port 6379 connected:

docker ps
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS               NAMES
b95c9402dd42        redis:3             "/entrypoint.sh redi   47 minutes ago      Up 47 minutes       6379/tcp            redisDev

      

I am trying to connect with the following code:

        var sb = new StringBuilder();
        var tw = new StringWriter(sb);
        ConnectionMultiplexer redis;
        try
        {
            redis = ConnectionMultiplexer.Connect("vb-haproxy01.verify.local", tw);
        }
        catch (Exception ex)
        {
            //Console.WriteLine(ex.Message);
            tw.Flush();

            Console.WriteLine(sb.ToString());
            return;
        }

      

I am getting the following error:

vb-haproxy01.verify.local:6379

1 unique nodes specified
Requesting tie-break from vb-haproxy01.verify.local:6379 > __Booksleeve_TieBreak
...
Allowing endpoints 00:00:05 to respond...
vb-haproxy01.verify.local:6379 faulted: SocketFailure on PING
vb-haproxy01.verify.local:6379 failed to nominate (Faulted)
> UnableToResolvePhysicalConnection on GET
No masters detected
vb-haproxy01.verify.local:6379: Standalone v2.0.0, master; keep-alive: 00:01:00;
 int: Connecting; sub: Disconnected; not in use: DidNotRespond
vb-haproxy01.verify.local:6379: int ops=0, qu=0, qs=0, qc=1, wr=0, sync=1, socks
=2; sub ops=0, qu=0, qs=0, qc=0, wr=0, socks=2
Circular op-count snapshot; int: 0 (0.00 ops/s; spans 10s); sub: 0 (0.00 ops/s;
spans 10s)
Sync timeouts: 0; fire and forget: 0; last heartbeat: -1s ago
resetting failing connections to retry...
retrying; attempts left: 2...
1 unique nodes specified

      

Linux firewall settings:

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:6379

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

      

What am I missing?

+3


source to share


1 answer


The problem is that port 6379 on the host was not forwarding port 6379 to docker. The "-p 6379: 6379" command fixed the problem:



docker run -d --name redisDev -p 6379:6379 redis

      

+4


source







All Articles