Docker – Local domain name resolution with WSL & Docker

dockerdomain-name-systemwindows-subsystem-for-linux

I'm developing an app that is a combination of a Chrome extension and Rails backend (plus redis, solr and postgres). I've recently switched to developing on my nice home Windows rig instead of my macbook. The extension (running in a chrome browser on Windows) needs to be able to talk to the host (https://company.localhost) backed by the Rails server running in the WSL2 (localhost:3000).

The dependencies (redis, solr, postgres) are hosted as Docker containers and are reachable by the server (just regular ole rails s) without issue. I'm down to switch the server to be dockerized as well, if that helps out.

On Mac, there's a magic tool that handles all this (puma-dev), including the S part of HTTPS.

I'm not even sure where to begin with Windows & the WSL. Any pointers?

PS – I'm looking at puma-dev on the WSL, but there's indications that that might not pan out.

Update: Have puma-dev setup properly inside the WSL, so ping company.localhost resolves as expected.

Best Answer

Here is what worked for me:

  1. Open windows hosts file c:\Windows\System32\Drivers\etc\hosts
  2. Add a binding for your puma domain to localhost 127.0.0.1 mysite.test
  3. Save and restart windows
Related Topic