February 2019
Intermediate to advanced
240 pages
5h 25m
English
Normally, to start a Rails server, we’d simply run bin/rails s, yet when we started the Rails server with docker run, we used bin/rails s -b 0.0.0.0. Why was that?
When you start the Rails server with bin/rails s, by default, it only listens to requests on localhost (or 127.0.0.1) on whatever machine it’s running on. This provides a secure default, preventing the Rails app server from being accessible externally. However, in our case, the server is running inside a container, but the request is coming from outside.
When we request http://localhost:3000 on our local machine, as we’ve just seen in Reaching the App: Publishing Ports, the request is forwarded to the Docker Engine. This in turn routes the ...