Skip to Content
Docker for Rails Developers
book

Docker for Rails Developers

by Rob Isenberg
February 2019
Intermediate to advanced
240 pages
5h 25m
English
Pragmatic Bookshelf
Content preview from Docker for Rails Developers

Reaching the App: Publishing Ports

As we know, containers are isolated sandboxes. How is it that we’re able to reach our app by visiting http://localhost:3000 on our local machine?

The truth is, containers wouldn’t be very useful if there was no way of reaching them from outside of Docker. The whole point of a web server, for example, is that it’s accessible to people making requests.

Although, by default, a container can only be accessed from within the Docker network it’s connected to (more on this in How Containers Can Talk to Each Other), we can make it accessible externally by publishing one or more ports with docker run’s -p option.

In our command, we specified -p 3000:3000; this publishes the container’s port 3000 (the second number) ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learn Rails 6: Accelerated Web Development with Ruby on Rails

Learn Rails 6: Accelerated Web Development with Ruby on Rails

Adam Notodikromo
Mastering Ruby Closures

Mastering Ruby Closures

Benjamin Tan Wei Hao

Publisher Resources

ISBN: 9781680506730Errata Page