I'm trying to run the tests using Makefile. I'm using behave, Selenium and selenium webdrivers and the issue that I face when I try to run the tests trough following command in Makefile:
$(DOCKER_EXEC) bash -c "behave test.feature --junit -D driver=firefox
is that I receive an error that: SessionNotCreatedException: Message: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary'. As if the firefox was not installed in this container.
I have even tried to run the tests on the selenium grid server, by specyfing those lines in docker-compose file:
selenium-hub:
image: selenium/hub:latest
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
firefox:
image: selenium/node-firefox:beta
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
And when I run the container I'm able to run the tests on my end on port 4444 trough visual studio using the very same command I use in Makefile but when I do the same trough the Makefile:
$(DOCKER_EXEC) bash -c "behave test.feature --junit -D driver=firefox -D remote="http://localhost:4444""
it says:
Failed to establish a new connection: [Errno 111] Connection refused.
I also tried to use the "jlesage/firefox" image instead but no luck here either.
Without it I'm unable to run my tests in Behave&Selenium using Makefile.
In advance, my docker skills aren't great so apologies if the answer is blatantly obvious.
TLDR: Locally run website which I need to specify the port to access, how do I allow a docker container to access that website?
More info:
I have two websites that I run locally:
The first is localapp.company.com that is an IIS site
The other is localnewapp.company.com that is run locally by vue-cli-service serve and can only be accessed by specifying the port localnewapp.company.com:8081
I'm trying to parallelize our cypress tests via docker containers
where {IPv4_ADDRESS} = My local IP Address, here is my docker-compose.yml file:
version: '3.2'
services:
cypress:
build: .
working_dir: /e2e
extra_hosts:
localnewapp.company.com: {IPv4_ADDRESS}
localapp.company.com: {IPv4_ADDRESS}
entrypoint: cypress run --headless --browser chrome --config-file ./cypress.json --record --key {KEY} --parallel --ci-build-id ${GITHUB_RUN_ID}
volumes:
- ./:/e2e
Cypress can run the tests that are for localapp but fail for localnewapp.
Using the Docker CLI, I've attempted to run:
curl localapp.company.com which returns a valid response.
curl localnewapp.company.com:8081 fails to connect.
Not sure where to go from here. Any suggestions would be greatly appriciated.
Edit:
Just to clarify, locally, port 8081 is in use by node.exe which is serving the website locally.
You will need to expose a port from your cypress service
ports:
- HOST_PORT:CONTAINER_PORT
like:
version: '3.2'
services:
cypress:
..
volumes:
- ./:/e2e
ports:
- 8081:8080
see the documentation
I'm having an issue trying to dockerize my webdriverIO testing framework and running the tests on the existing selenium/standalone-chrome image with docker-compose.
I have a simple dockerfile to build the app such as this:
FROM node:12
ADD . /app
WORKDIR /app
RUN npm install
Then I have a docker-compose.yaml to build the stack and run the tests:
version: "3"
services:
app:
build: .
command: npm test -- --host selenium
links:
- selenium
selenium:
network_mode: host
image: selenium/standalone-chrome
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
My conf.js file sets the host and port like so:
exports.config = {
host: 'selenium',
port: 4444,
No matter what I try, I continue to get the following error after docker-compose build and docker-compose up:
[0-9] Error: Failed to create session.
app_1 | Unable to connect to "http://127.0.0.1:4444/", make sure browser driver is running on that address.
app_1 | If you use services like chromedriver see initialiseServices logs above or in wdio.log file as the service might had problems to start the driver.
Any helpful information on why I would see this type of error would be helpful. Thanks in advance.
I am currently setting up a buildkite build pipeline which runs an api in one docker container and an application in another docker container alongside it while running Cypress tests (which are also running within the second container).
I use the following docker compose file:
version: '3'
services:
testing-image:
build:
context: ../
dockerfile: ./deploy/Dockerfile-cypress
image: cypress-testing
cypress:
image: cypress-testing
ipc: host
depends_on:
- api
db:
image: postgres:latest
ports:
- "54320:5432"
redis:
image: redis:latest
ports:
- "63790:6379"
api:
build:
context: ../api/
dockerfile: ./Dockerfile
image: api
command: /env/development/command.sh
links:
- db
- redis
depends_on:
- db
- redis
The application runs in the cypress container when started by buildkite. It then starts the cypress tests and some of them pass. However, any test that requires communication with the API fails because the cypress container is unable to see localhost within the API container. I am able to enter the API container using a terminal and have verified that it is working perfectly internally using cURL.
I have tried various URLs within the cypress container to try to reach the API, which is available on port 8080 within the API container, including api://api:8080 and http://api:8080 but none of them have been able to see the API.
Does anybody know what could be going on here?
[https://github.com/gtriggiano/ngrok-tunnel ] runs ngrok inside a container. Ngrok is required to run in the container to avert security risks. But am facing problems after running the scripts, which generates the url
$ docker pull gtriggiano/ngrok-tunnel
$ docker run -it -e "TARGET_HOST=localhost" -e "TARGET_PORT=3000" -p 4040 gtriggiano/ngrok-tunnel
am running my rails app on localhost:3000
is it my problem or can it be fixed by altering the scripts(inside the repo)?
I couldn't get this working but switched to https://github.com/shkoliar/docker-ngrok and it works brilliantly.
In my case I added it to my docker-compose.yml file:
ngrok:
image: shkoliar/ngrok:latest
ports:
- 4551:4551
links:
- web
environment:
- PARAMS=http -region=eu -authtoken=${NGROK_AUTH_TOKEN} localdev.docker:80
networks:
dev_net:
ipv4_address: 10.5.0.10
And it's started with everything else when I do docker-compose up -d
Then there's a web UI at http://localhost:4551/ for you to see the status, requests, the ngrok URLs, etc.
The Github page does have examples of running it manually from the command line too though, rather than via docker-compose:
Command-line Example The example below assumes that you have running
web server docker container named dev_web_1 with exposed port 80.
docker run --rm -it --link dev_web_1 shkoliar/ngrok ngrok http dev_web_1:80
With command line usage, ngrok session is active until it
won't be terminated by Ctrl+C combination.
No. if you execute -p with single number it's container port - host port is randomly assigned.
Using -p, --publish ip:[hostPort]:containerPort at docker run can specify the the host port with the container port.
as of now the 4040 of container is exposed. Not sure if your service listens by default on it.
To get localhost port execute
docker ps
you'll see the actual port it's not listening on.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1aaaeffe789d gtriggiano/ngrok-tunnel "npm start" About a minute ago Up About a minute 0.0.0.0:32768->4040/tcp wizardly_poincare
here it's listening on localhost:32768
this composer works for me. Note that in the entrypoint command for ngrok you have to reference the other service by name
version: '3'
services:
yourwebserver:
build:
context: ./
dockerfile: ...
target: ...
container_name: yourwebserver
volumes:
- ...
ports:
- ...
extra_hosts:
- 'host.docker.internal:host-gateway'
depends_on:
- ngrok
ngrok:
image: ngrok/ngrok:alpine
environment:
NGROK_AUTHTOKEN: '...'
command: 'http yourwebserver:80'
ports:
- '4040:4040'
expose:
- '4040'
I'm not sure if you have already solved this but when I was getting this error I could only solve it like this:
# docker-compose.yml
networks:
- development
I also needed to expose the 3000 port of my web container because it still wasn't exposed.
# docker.compose.yml
web:
expose:
- "3000"
My container for the server running on development is also under the development network. The only parameters, I believe, you should pass for the container to execute are image, ports, environment with DOMAIN and PORT for the server container, a link, and an expose on your web container:
# docker-compose.yml
ngrok:
image: shkoliar/ngrok
ports:
- 4551:4551
links:
- web
networks:
- development
environment:
- DOMAIN=squad_web
- PORT=3000
Actually to make ngrok work with your docker container you can install it outside of your project just like the manual on their website says. And then add
nginx:
labels:
- "traefik.http.routers.${PROJECT_NAME}_nginx.rule=Host(`${PROJECT_BASE_URL}`, `aaa-abc-xxx-140-177.eu.ngrok.io`)"
This particular example is for docker4drupal docker-compose file and traefik mapped as 80:80