How to: Run Sql Server and Redis using Docker on Windows

Sql Server is great and so is Redis but once I install them on my DEV machine they take (at times significant) amount of PC resources so I’ve switched to Docker-based solution which is simple to set up and it solves this problem.

Basically, you need to execute this 3 simple steps:

  1. install Docker (just run the installer from
  2. Install Sql 2019  Linux docker image by following next steps
    After this steps you will be able to connect to the server using Managment Studio and/or Entify Framework is using it normally.
  3. Pull redis docker image (docker pull redis) and run it locally with this command
docker pull redis

docker run  -d -p 6379:6379 redis

Then in your appsettings.json just put „localhost“ for redis server address and you are done.

The two things I like about this approach to setting up my DEV box:

  •  If the docker containers are not running there is no impact on the hosting PC
  • I can use the same simple setup for my windows and mac dev machines

Gotcha: OPTIONS preflight call getting 401 Unauthorized

This one is a quite stupid problem but as it took me 2 hours to figure it out I’ve decided to write it down.

The problem was related to the fact that on a given controller I had a method

public async Task<LookupData> GetAsync()

which I expected based on my WebAPI v1 days to be HttpGet ONLY by convention.

What I have learned is that is not the case in AspNetCore so this method was triggered also by CORS preflight OPTIONS call and that caused all kind of troubles.

Solution to my problem ended very simple – add a [HttpGet] attribute

public async Task<LookupData> GetAsync()

I somehow don’t like to use attributes when I don’t really have to but in this case lesson learn – annotate your AspNetCore controller methods! 🙂

Real-user monitoring for Accessibility, Performance, Security, SEO & Errors (SiteLint)