Building your own docker images of SeleniumHQ/docker-selenium - selenium

I'm not sure if it is a bug or just me being stupid but here is the case.
I want to build my image based on StandaloneChromeDebug. Following the Wiki:
Pull the repo.
Generate image:
$ make standalone_chrome_debug
Build the Dockerfile to insure that no errors arise:
$ docker build --no-cache etc/docker-selenium/StandaloneChromeDebug/
Set up my image to the docker-compose.yml like:
selenium-hub:
container_name: selenium-hub
build: ./etc/docker-selenium/StandaloneChromeDebug/
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
- "5900:5900"
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
And... nothing. The container is running (no errros) but Selenium doesn't work, container log is empty, /opt/ folder is empty. What am i doing wrong? How to debug the thing?

Path is wrong, use build: /etc/docker-selenium/StandaloneChromeDebug/ without .
If you try to cd to ./etc/docker-selenium/StandaloneChromeDebug/, you will get an error.
version: "3.5"
services:
selenium-hub:
container_name: selenium-hub
build: /etc/docker-selenium/StandaloneChromeDebug/
volumes:
- /dev/shm:/dev/shm
ports:
- "4444:4444"
- "5900:5900"
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
Exapmle:

I feel you are using "build" tag in your compose file rather than "image". Please use "image" tag instead and see if that runs your image correctly.
Also can you please show how you are launching your docker services and what the output is?
Reference to build command

Related

How to configure selenoid to use a specific version of selenoid/video-recorder to be used to record session

is there any way to mention which version of selenoid/video-recorder should be used while selenoid is started? either in docker-compose.yml or command line?
I get following error, due to the docker pull limit issue, so I need to mention the specific version i have pulled earlier.
2021/04/08 10:35:59 [909] [5.64s] [SESSION_FAILED] [test] [x.x.x.x] [chrome-89.0] [x.x.x.x:4444] [-] [6] [start video container: create video container: Error response from daemon: No such image: selenoid/video-recorder:latest-release]
Following is my docker compose file.
version: '3'
services:
selenoid:
network_mode: bridge
image: aerokube/selenoid:1.10.1
volumes:
- "/opt/selenoid:/etc/selenoid"
- "/var/run/docker.sock:/var/run/docker.sock"
- "/opt/selenoid/video:/opt/selenoid/video"
environment:
- OVERRIDE_VIDEO_OUTPUT_DIR=/opt/selenium/video
- TZ=America/Montreal
- limit=10
command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video"]
ports:
- "4444:4444"
selenoid-ui:
image: "aerokube/selenoid-ui"
network_mode: bridge
links:
- selenoid
ports:
- "8080:8080"
command: ["--selenoid-uri", "http://selenoid:4444"]
Respective image can be specified with -video-recorder-image flag in in command section. All available flags are listed here: https://aerokube.com/selenoid/latest/#_selenoid_cli_flags

Variable substitution in docker-compose command

I need to pass env variable from file to a command in a docker-compose but it seems impossible.
So I try first with environment var but it doesn't work again. How can I do that?
version: '3'
services:
nginx-service-xxx:
image: service-xxx-nginx:latest
ports:
- 80:80
restart: always
service-xxx:
image: service-xxx:latest
# env_file:
# - db-settings.env
environment:
- PORT=80
- PG-HOST=192.168.0.101
- PG-DATABASE=xxx
- PG-USER=postgres
- PG-PASSWORD=postgres
restart: always
command: python xxx/main.py --port=$$PORT --pg-host=$$PG-HOST --pg-database=$$PG-DATABASE --pg-user=$$PG-USER --pg-password=$$PG-PASSWORD
try to move the complexity of the command to a docker entry point.
First, you need to add the following entry point to your project (make it executable)
#!/bin/bash -e
case $1 in
web)
python xxx/main.py --port=$PORT --pg-host=$PG-HOST --pg-database=$PG-DATABASE --pg-user=$PG-USER --pg-password=$PG-PASSWORD
;;
*)
exec "$#"
;;
esac
exit 0
update the docker file for your service
From base-image
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
update compose
version: '3'
services:
nginx-service-xxx:
image: service-xxx-nginx:latest
ports:
- 80:80
restart: always
service-xxx:
image: service-xxx:latest
environment:
- PORT=80
- PG-HOST=192.168.0.101
- PG-DATABASE=xxx
- PG-USER=postgres
- PG-PASSWORD=postgres
restart: always
command: web

Build failure while trying to use docker-compose build step

I am trying to execute my selenium test on Jenkins node (Ubuntu) which has docker already installed. I added docker-compose build step plugin to my Jenkins project. When i try to build the project, I am getting an error in console -
$ docker-compose -f /home/jenkins/workspace/OM/TestWDM/docker-compose.yml up -d
Build step 'Docker Compose Build Step' changed build result to FAILURE
I am able to execute the project successfully on my local machine. I do have docker-compose.yml file in the root directory. I tried docker ps -a command just to see if it's partially . working, but it's not.
docker-compose file:
version: "3"
services:
selenium-hub:
restart: always
image: selenium/hub:latest
ports:
- "4444:4444"
#selenium-chrome
selenium-chrome:
restart: always
image: selenium/node-chrome-debug
stdin_open: true
links:
- selenium-hub:hub
#selenium-firefox
selenium-firefox:
restart: always
image: selenium/node-firefox-debug
links:
- selenium-hub:hub
chrome:
image: selenium/node-chrome
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
firefox:
image: selenium/node-firefox
depends_on:
- selenium-hub
environment:
- HUB_PORT_4444_TCP_ADDR=selenium-hub
- HUB_PORT_4444_TCP_PORT=4444
The reason I am trying to use docker here because I was facing an issue with chrome binary not found without it. My expectation over here was to have my test run successfully on Jenkins node.

Docker-The scale command is deprecated. Use the up command with the --scale flag instead

i want to launch 5 chrome and 5 firefox in docker container. I am using the below command but its giving the following error
The scale command is deprecated. Use the up command with the --scale flag instead.
ERROR: No such service: nodechrome
docker-compose scale nodechrome=5 nodefirefox=5
My docker-compose.yml file
version: '2'
services:
firefoxnode:
image: selenium/node-firefox-debug
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
ports:
- "32772:5900"
chromenode:
image: selenium/node-chrome-debug
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
ports:
- "32773:5900"
hub:
image: selenium/hub
ports:
- "4444:4444"
From where these names came? nodechrome and nodefirefox
Correct your command instead:
from:
docker-compose scale nodechrome=5 nodefirefox=5
to:
docker-compose scale chromenode=5 firefoxnode=5
Try this command:
docker-compose up --scale chrome=5
Verify the Grid by visiting: http://localhost:4444/ui/index.html#/
Refer: Documentation

Unable to Take Screenshots Using Firefox Nodes

My Selenium tests are designed to take screenshots on failure and add them to the report. The screenshots are displaying perfectly for chrome browsers, but Firefox screenshots are just white rectangles.The changelog says something about a "pass through" mode https://github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG which I've tried to disable, but nothing seems to be working.
Here's my docker compose file:
seleniumhub:
image: selenium/hub
ports:
- 4444:4444
firefoxnode:
image: selenium/node-firefox-debug
ports:
- 4577
links:
- seleniumhub:hub
environment:
- enablePassThrough=false
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5
chromenode:
image: selenium/node-chrome-debug
ports:
- 4578
links:
- seleniumhub:hub
environment:
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5
I don't think enablePassThrough is a valid environment variable. The configuration is generated from https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeFirefox/generate_config which only contains your NODE_MAX_INSTANCES and NODE_MAX_SESSION.
However, there is a SE_OPTS variable from the parent base image in the entrypoint at https://github.com/SeleniumHQ/docker-selenium/blob/master/NodeBase/entry_point.sh#L28-L30. You can use this to set -enablePassThrough false. Your service definition in Docker Compose would be something like this instead:
firefoxnode:
image: selenium/node-firefox-debug
ports:
- 4577
links:
- seleniumhub:hub
environment:
- SE_OPTS="-enablePassThrough false"
- NODE_MAX_INSTANCES=5
- NODE_MAX_SESSION=5