How to access the local Rails puma server inside a Docker container?

Asked

Viewed 60 times

-1

I’ll try to be as clear as I can.

To put it in context: I have an application that has tests written in Capybara and that connects remotely to a Docker container to run the tests. As I use the WSL, running the local Chrome is something that is not yet possible, so I use this container from Selenium.

The problem: From inside my Selenium container I cannot access the application that is running locally on my machine. I find many solutions when it comes to a Ocker needing to somehow access another, but that’s not the case, nor is it the case to expose Ocker doors, because the connection I need is from the inside out and not the other way around. Ex: I want to be able to type http://192.168. 1.5:3000 (ip of my local machine) from inside the container and have it find my Rails application running on my local machine.

PS. I run inside a WSL, so the ip of my network in windows and WSL are different, but if I access this way by windows in the WSL ip I find the application, because from inside the container this is not a truth?

Can someone help me?

EDIT: I deleted all containers, all images and all Networks from Docker and started again and so far it’s working.

1 answer

1


To access the host from within a container, there is a specific address of the Docker, and it is not necessary to use the IP, since it may vary.

Use the address host.docker.internal and the port you want (from the host).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.