I have two containers, one running a Node.js process that launches protractor, and another running a standalone Selenium container. The file looks like this:
version: '2'
services:
www.example.localhost:
build: .
depends_on:
- selenium
dns_search:
- static.example.localhost
extra_hosts:
- "static.example.localhost:127.0.0.1"
ports:
- "3000:3000"
- "4000:4000"
volumes:
- ./src:/code/src
- ./api:/code/api
entrypoint: "npm run"
command: "test:e2e"
selenium:
dns_search:
- selenium.example.localhost
image: selenium/standalone-chrome-debug:2.52.0
environment:
no_proxy: localhost
volumes:
- /dev/urandom:/dev/random
ports:
- "4444:4444"
- "6900:5900"
www.example.localhost runs protractor, which in turn connects to the selenium container with these lines in protractor.config.js:
seleniumAddress: "http://selenium:4444/wd/hub",
directConnect: false,
When I run VNC on the selenium container, open up the chrome browser inside the container and type www.example.localhost:3000 it fails to resolve the domain. However when I run wget www.example.localhost:3000 it gets the index.html file just fine. Any idea what I'm doing wrong?
Turns out in Google Chrome, any domain ending in localhost resolves to 127.0.0.1, no matter what DNS settings you have. Changing the domain from .localhost to .dev fixes it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With