When working with Rails, I like to test my web apps with my desktop browser and my mobile browser. I like using my mobile browser, especially to test the PWA setup.

To be able to test the development version running in Docker with my devcontainer setup, I use Ngrok.

You need to register and install the CLI from here https://dashboard.ngrok.com/get-started/setup/linux

Once you have ngrok installed in your Docker container, you can setup your Rails app to allow connections from Ngrok urls. Open config/environments/development.rb and add the following line:

  config.hosts << '.ngrok-free.app'

Start your Rails server as usual, and then on a new console run:

ngrok http http://localhost:3000

Ngrok will give you a public URL you can use on your phone to connect directly to your docker container.

Enjoy ✌️