Reputation: 8922
I m trying to create some containers that aim to build my javascript application.
Here's what I need to do :
Here's my project dockerfile :
FROM node:6.9
# Enviroment variables
ENV HOMEDIR /data
RUN mkdir -p ${HOMEDIR}
WORKDIR ${HOMEDIR}
# install all dependencies
ADD package.json ./
RUN npm install
# add node content initially
ADD . .
CMD CI=true npm test && npm run build && npm run test:acceptance
The fact is that when I start my acceptance tests, I need to use a selenium server and a phantomjs browser. This way, and thanks to the stackoverflow community, I created a docker-compose.yml file that looks like :
version: '2'
services:
hub:
image: selenium/hub
ports:
- "4444:4444"
phantomjs:
image: akeem/selenium-node-phantomjs
depends_on:
- hub
links:
- hub
app:
build: .
depends_on:
- hub
- phantomjs
My selenium-phantomjs well connects to my selenium/hub, and selenium is available at localhost:4444 on my host machine.
My real problem is that my tool to achieve acceptance testing (webdriverio) doesn't seem to be able to contact the selenium server, and I don't know why.
I'm having the following stack :
app_1 | [08:24:07] COMMAND POST "/wd/hub/session"
app_1 | [08:24:07] DATA {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"maxInstances":5,"browserName":"phantomjs","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.6.1","name":"webdriverio"}}}
app_1 | ERROR: Couldn't connect to selenium server
app_1 | phantomjs
app_1 | Error: Couldn't connect to selenium server
app_1 |
app_1 | Wrote xunit report to [./xunit].
Any suggestion ?
Thanks for your help
Upvotes: 2
Views: 657
Reputation: 4677
If you are running your test-scripts from within another container, then the wd_host
parameter needs to be set to http://hub:4444/wd/hub
, instead of http://localhost:4444/wd/hub
(default).
The links:
field makes hub
available under the hostname hub
, not as localhost
, to the other container.
The ports:
field is only used to access containers from your host machine, it doesn't affect what containers themselves can access.
Upvotes: 1