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

URL base and port #10

Open
AndreKR opened this issue Feb 2, 2018 · 10 comments
Open

URL base and port #10

AndreKR opened this issue Feb 2, 2018 · 10 comments

Comments

@AndreKR
Copy link

AndreKR commented Feb 2, 2018

Just a remark because it confused me:

The combinations of port and URL base that I have seen so far are:

URL base Port Used by
/wd/hub 4444 Selenium
<empty> 9515 Chromedriver default
<empty> 4444 This Dockerfile

In your Dockerfile you have decided to go with port 4444 and URL base <empty>, is there a particular reason for that?

@RobCherry
Copy link
Owner

This was originally based on an implementation using selenium webdriver. In all honestly I think this was developed after https://github.com/RobCherry/docker-selenium, although I am no longer 100% sure since it has been a while.

@et
Copy link

et commented Feb 6, 2018

Is it it possible to customize the port? I need it to run on port 9515.

@AndreKR
Copy link
Author

AndreKR commented Feb 6, 2018

@et Since it's a docker image, you can just map the port to whatever you like when running the container, change -p 127.0.0.1::4444 to -p 127.0.0.1:9515:4444 in your docker run.

If you don't what to see "4444" at all because it makes you think that you are working with Selenium, you can also set the environment variable CHROMEDRIVER_PORT to change the port inside the container.

@et
Copy link

et commented Feb 6, 2018

@AndreKR - in order to change the env var, I would need to push up my own image, correct? Sorry, if this is a n00b question, still on the dipping my feet with Docker.

@et
Copy link

et commented Feb 6, 2018

Let me rephrase that last question...is it possible to map a port when using this with docker-compose?

@AndreKR
Copy link
Author

AndreKR commented Feb 6, 2018

The docker syntax to set an environment variable is -e "CHROMEDRIVER_PORT=9515".

The docker-compose.yml syntax to map a port is:

ports:
  - "127.0.0.1:9515:4444"

The docker-compose.yml syntax to set an environment variable is:

environment:
  CHROMEDRIVER_PORT: 9515

@et
Copy link

et commented Feb 6, 2018

Excellent! Thank you @AndreKR 😄

@iamsoorena
Copy link

hey guys, I want to use this docker image as a runner for my selenium tests, but I couldn't connect. I'm using this snippet:

  const webdriver = require('selenium-webdriver')
  const driver = util(new webdriver.Builder().forBrowser('chrome').usingServer('http://localhost:32769/wd/hub').build())

and result of my docker ps is:

CONTAINER ID        IMAGE                                  COMMAND                  CREATED             STATUS              PORTS                     NAMES
1cce19fe2a47        robcherry/docker-chromedriver:latest   "/usr/local/bin/supe…"   4 seconds ago       Up 3 seconds        0.0.0.0:32769->4444/tcp   chromedriver

that results in this error:

Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
    at ClientRequest.<anonymous> (/.../index.js:238:15)
    at emitOne (events.js:116:13)
    at ClientRequest.emit (events.js:211:7)
    at Socket.socketErrorListener (_http_client.js:387:9)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at emitErrorNT (internal/streams/destroy.js:64:8)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
From: Task: WebDriver.createSession()
    at Function.createSession (/.../webdriver.js:769:24)
    at Function.createSession (/..../chrome.js:761:15)
    at createDriver (/.../index.js:170:33)
    at Builder.build (/..../index.js:626:16)
    at repl:4:6
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at REPLServer.defaultEval (repl.js:240:29)
    at bound (domain.js:301:14)
    at REPLServer.runBound [as eval] (domain.js:314:12)
    at REPLServer.onLine (repl.js:441:10)

what's wrong?!

@et
Copy link

et commented Apr 11, 2018

What does lsof -i :4444 report?

@RobCherry
Copy link
Owner

@iamsoorena Be sure to set the CHROMEDRIVER_WHITELISTED_IPS environment variable in the container if you want it to allow outside connections. By default it restricts access to localhost (127.0.0.1).

You can open it up to all IPs by setting it to an empty string, or specify the IPs you want to use.

For example if you want to allow all IPs then add this to your docker run command: -e CHROMEDRIVER_WHITELISTED_IPS=''

See the notes at the bottom of the readme for more information.

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

No branches or pull requests

4 participants