Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure binding is always 0.0.0.0. #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

viktorianer
Copy link

@viktorianer viktorianer commented Oct 3, 2024

Description

This PR updates the Dockerfile to ensure the Rails server binds to all available IP addresses (0.0.0.0). This change allows the Rails app to be accessed externally from outside the container.

For a working example of this configuration in action, you can refer to viktorianer/rails8-devcontainer-enhancements#5. This showcases the same binding solution applied in a Rails app.

Why this is needed

While the default binding to localhost works with Docker in most cases, issues can arise when using alternative container runtimes like Podman. These runtimes may restrict access to services inside containers when they are bound only to localhost. By explicitly setting the binding to 0.0.0.0, the Rails app becomes accessible externally on port 3000 across all runtimes, including Podman.

Impact

  • Fix for Podman and other alternative runtimes: Resolves issues where the Rails app could not be accessed from outside the container.
  • The Rails app will now be reachable on http://localhost:3000 from external connections.

Binds the server to all IP addresses of the container, so it can be accessed from outside the container.
@andrewn617
Copy link
Collaborator

Hi @viktorianer thanks for the PR. I think it makes sense to do this as we want to support dev containers with Docker. (On a side note, I had a hard time with podman since podman-compose didn't seem to play nicely with vscode).

However, I am not sure this is the right layer for the solution. This is just a ruby image, so it's not necessarily true the container using this image will even be running a server that needs to be accessed externally. So in that case, perhaps a better solution is to add this to the Dockerfile in Rails, since the use case seems Rails specific. WDYT?

@viktorianer
Copy link
Author

@andrewn617

You’re absolutely right. However, I initially thought this image was meant specifically for Rails. That was a misunderstanding on my part.

Would it make sense to reopen this PR in the Rails repository instead? What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants