Connecting to Redis hosted in docker on Windows 10 Pro

I have just setup redis using docker in windows and I am trying to write a simple .Net console app to connect to it to familiarize myself with things.

I am running docker in windows 10 pro using “docker run redis:windowsservercore”

The redis instance looks like it boots up fine and will display:

[1904] 21 Mar 13:18:50.835 # Server started, Redis version 3.2.100

[1904] 21 Mar 13:18:50.847 – The server is now ready to accept connections on port 6379

But in my app when I try to connect to localhost:6379 it seems as if it can’t find the redis instance at all:

var log = new StringWriter();
try
{
    StackExchange.Redis.ConnectionMultiplexer RedisConnection = StackExchange.Redis.ConnectionMultiplexer.Connect("localhost:6379", log); // This line errors
    var cache = RedisConnection.GetDatabase(1);
    cache.StringSet("Test", "Hello World");
    Console.WriteLine(cache.StringGet("Test"));
}
catch (Exception ex) { }

The connection above always fails with:

“It was not possible to connect to the redis server(s). UnableToConnect on localhost:6379/Interactive, Initializing/NotStarted, last: NONE, origin: BeginConnectAsync, outstanding: 0, last-read: 2s ago, last-write: 2s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 9s ago, v: 2.1.0.1”

I just can’t figure out what I am doing wrong here. I have tried connecting using other naming methods for localhost. I disabled all firewalls for public and private networks to ensure this wasn’t the issue.

I am note sure what I need to do here to get a connection established, hopefully someone has some advice for me.

Thanks everyone in advance

Source: StackOverflow