Open AndreKR opened 6 years ago
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.
Is it it possible to customize the port? I need it to run on port 9515.
@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.
@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.
Let me rephrase that last question...is it possible to map a port when using this with docker-compose
?
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
Excellent! Thank you @AndreKR 😄
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?!
What does lsof -i :4444
report?
@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.
Just a remark because it confused me:
The combinations of port and URL base that I have seen so far are:
/wd/hub
In your Dockerfile you have decided to go with port 4444 and URL base \ , is there a particular reason for that?