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

Cannot connect to docker.for.mac.localhost #511

Closed
alxlu opened this Issue Jun 28, 2017 · 11 comments

Comments

Projects
None yet
5 participants
@alxlu
Copy link

alxlu commented Jun 28, 2017

Meta -

Image(s):
node-chrome(-debug)
Docker-Selenium Image Version(s):
latest

OS:
macOS

Expected Behavior -

Navigating to docker.for.mac.localhost:PORT on Google Chrome will resolve to the internal IP used by the host.

Actual Behavior -

docker.for.mac.localhost refused to connect.
If I connect to the container with VNC and run wget docker.for.mac.localhost:8080, it's able to successfully resolve the IP and download the file. It also seems to be working properly on node-firefox.

@ddavison

This comment has been minimized.

Copy link
Member

ddavison commented Jun 30, 2017

could we see the command you are using / script that you're using to run against that uri?

@alxlu

This comment has been minimized.

Copy link
Author

alxlu commented Jun 30, 2017

Sure! I'm running my tests with webdriver.io, and just navigating to it using

browser.url(`${URL}/upload`);
// URL is passed in as an env variable--in this case pointing to
// http://docker.for.mac.localhost:8080

Also, the issue can be reproduced by using the config below, VNCing into them, and then manually navigating to the uri.

docker-compose.yml

selenium-hub:
  image: selenium/hub
  ports:
    - "4444:4444"
chrome:
    image: selenium/node-chrome-debug
    ports:
      - "9000:5900"
    links:
      - selenium-hub:hub
firefox:
    image: selenium/node-firefox-debug
    ports:
      - "9001:5900"
    links:
      - selenium-hub:hub

You can start any kind local web server on the host (e.g. python -m SimpleHTTPServer) in any directory, then VNC into both the Firefox and Chrome containers and launch their respective browsers and manually navigate them to http://docker.for.mac.localhost:8000

Firefox navigates to it properly, but Chrome does not

screen shot 2017-06-30 at 2 57 32 pm

@ddavison

This comment has been minimized.

Copy link
Member

ddavison commented Jun 30, 2017

i'm not a javascript guy, but could it be the use of the grave?

in most languages,

'' != ""
"" != ``

have you tried with single/double quotes?

EDIT
the screenshots have your URL pointing to 8000, not 8080 as you previous stated.. could this be the problem? URL actually has 8000 as the port?

@alxlu

This comment has been minimized.

Copy link
Author

alxlu commented Jun 30, 2017

That's a template literal, but the issue isn't with JS since it can't navigate there even if you VNC in and manually enter the address.

Sorry if I was a little unclear—8080 is from my project, but I figured it would be easier to reproduce the problem by spinning up the docker containers, and creating any kind of local web server and manually navigating to the address. The screenshots are from running python -m SimpleHTTPServer which defaults to 8000.

@ddavison

This comment has been minimized.

Copy link
Member

ddavison commented Jun 30, 2017

hrm.. ah no problem :) just trying to eliminate the obvious!

since it can't navigate there even if you VNC in and manually enter the address.

I'm under the assumption based on your issue, you meant

since it CAN navigate there even if you VNC in and manually enter the address.

if this is the case, then i cannot imagine what's going wrong here. i'll be flying home tomorrow, so probably won't be able to get back to this issue in a while; hopefully @diemol can chime in here.

@alxlu

This comment has been minimized.

Copy link
Author

alxlu commented Jun 30, 2017

Oh, I meant Chrome can't navigate there even if you VNC in there manually. However, Firefox can. Also, other tools within the Chrome container are able to such as wget.

EDIT—I just realized what you meant (and I think we're on the same page). To clarify: you CAN attempt to navigate there in VNC, but it WON'T load in Chrome.

screen shot 2017-06-30 at 3 31 30 pm

@diemol

This comment has been minimized.

Copy link
Member

diemol commented Jul 9, 2017

Sorry to jump in so late. I ran into the same issue recently, and I am asking about it here moby/moby#22753

I am assuming that it is entirely an issue related to Chrome. But we need to check if we need to adjust something in the config for Chrome, somehow I guess it is not getting this DNS entry.

@diemol

This comment has been minimized.

Copy link
Member

diemol commented Jul 9, 2017

Hi @alxlu,
After Googling for a while and checking different links, this issue explains it briefly: docker/for-mac#1837

So, it is an issue between docker and Chrome, since Chrome is not going to resolve the hostname.

As a workaround, I suggest to use the IP 192.168.65.1 instead of the docker.for.mac.localhost. Also to follow up on the issue to see how it ends up.

Hopefully docker will change the name, since localhost should be only for local traffic.

I'll close this issue since it is not related to docker-selenium.

@jedwards1211

This comment has been minimized.

Copy link

jedwards1211 commented Dec 18, 2017

@diemol I tried 192.168.65.1 and Chrome complains that "There is no internet connection" even though Firefox connects to that IP just fine.

@jedwards1211

This comment has been minimized.

Copy link

jedwards1211 commented Dec 18, 2017

Nevermind, I forgot that a program I'm running called Freedom messes up networking for some Docker images.

@u007

This comment has been minimized.

Copy link

u007 commented Aug 10, 2018

i have the same issue, firefox works, but not chrome.
i did not have any kind of custom network except running local dns that resolved to cloudflare dns 1.1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.