Building & running a custom selenium container for DockerDesktop

221 views
Skip to first unread message

Marky Mark

unread,
Jun 3, 2021, 1:56:20 PM6/3/21
to Selenium Users
I wanted to build a custom container image that will use Chrome Canary for browser automation.
I've already used pre-built images from SeleniumHQ/docker-selenium project, such as the one for Firefox & Chrome and they do work fine when loaded in DockerDesktop.

I'm on  latest mac OS where I installed the DockerDesktop app.

on how to build a custom container image for Canary.
Basically, I cloned the GitHub project: 'SeleniumHQ/docker-selenium '
Then I run the command from terminal:

BUILD_ARGS="--build-arg CHROME_DRIVER_VERSION=91.0.4472.19 --build-arg CHROME_VERSION=google-chrome-unstable" NAME=node-chrome-canary-debug make chrome

This builds the image. The tail build output is as follows:

 => exporting to image                                                                                                                      
 => => exporting layers                                                                                                                      
 => => writing image sha256:863ff2a8fe9bf02d3dce7eb004b4b6b97b06f418693bee92f8226a8719c29638     

I then head over to my own project where I already have my docker-compose.yml with instructions:

------------- cut -------------------
version: "3.7"
services:
selenium-hub:
environment:
- GRID_MAX_SESSION=40
- GRID_TIMEOUT=1800
image: selenium/hub:3.141.59-20201119
ports:
- 4444:4444
restart: unless-stopped
node-chrome:
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
- NODE_MAX_INSTANCES=20
- NODE_MAX_SESSION=20
depends_on:
- selenium-hub
image: selenium/node-chrome-debug:3.141.59-20201119
ports:
- 5900:5900
volumes:
- /dev/shm:/dev/shm
restart: unless-stopped
---------------

and I just append to this file, a new section --> for my newly built image (i.e. for Canary):

------------------- cut -----------------
node-chrome-canary:
environment:
#- HUB_HOST=selenium-hub
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4444
- SE_EVENT_BUS_SUBSCRIBE_PORT=4444
#- HUB_PORT=4444
- NODE_MAX_INSTANCES=20
- NODE_MAX_SESSION=20
depends_on:
- selenium-hub
ports:
- 5901:5900
volumes:
- /dev/shm:/dev/shm
restart: unless-stopped
------------------------------------------------
I save the file and then from my own project I run:
docker-compose up -d
which will start the images specified in above file.

Then I run DockerDesktop. Within DockerDesktop, I see that my newly added image for Canary starts, but is not able to do a registration (presumably with Selenium Hub) because it keeps logging a registration message (see bottom logs below).
How can I fix this ? 
Isn't port 4444 the one that is supposed to be used ? The other image (the one for Chrome) also uses 4444 and is ok. 

I should mentioned that I'm connect to VPN.

Note that with my newly appended section, I couldn't use the environment variables such as: 'HUB_HOST' but rather I used 'SE_EVENT_BUS_HOST' (that is why I commented out the HUB_HOST line in my yml file, above)

Thank you !!

--------------- console output -----

2021-06-01 14:00:23,177 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing

2021-06-01 14:00:23,180 INFO supervisord started with pid 11

2021-06-01 14:00:24,182 INFO spawned: 'xvfb' with pid 13

2021-06-01 14:00:24,184 INFO spawned: 'vnc' with pid 14

2021-06-01 14:00:24,187 INFO spawned: 'novnc' with pid 15

2021-06-01 14:00:24,190 INFO spawned: 'selenium-node' with pid 16

2021-06-01 14:00:24,241 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-06-01 14:00:24,241 INFO success: vnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-06-01 14:00:24,242 INFO success: novnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-06-01 14:00:24,242 INFO success: selenium-node entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

Configuring server...

Setting up SE_NODE_HOST...

Setting up SE_NODE_PORT...

Setting up SE_NODE_GRID_URL...

Selenium Grid Node configuration:

[events]

publish = "tcp://selenium-hub:4444"

subscribe = "tcp://selenium-hub:4444"

[node]

session-timeout = "300"

override-max-sessions = false

detect-drivers = false

max-sessions = 1

[[node.driver-configuration]]

name = "chrome"

stereotype = '{"browserName": "chrome", "browserVersion": "92.0", "platformName": "Linux"}'

max-sessions = 1

Starting Selenium Grid Node...

14:00:26.052 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding

14:00:26.064 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing

14:00:26.815 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://selenium-hub:4444 and tcp://selenium-hub:4444

14:00:26.955 INFO [UnboundZmqEventBus.<init>] - Sockets created

14:00:27.967 INFO [UnboundZmqEventBus.<init>] - Event bus ready

14:00:29.129 INFO [NodeServer.createHandlers] - Reporting self as: http://172.29.0.3:5555

14:00:29.263 INFO [NodeOptions.getSessionFactories] - Detected 2 available processors

14:00:29.564 INFO [NodeOptions.report] - Adding chrome for {"browserName": "chrome","browserVersion": "92.0","platformName": "Linux"} 1 times

14:00:29.620 INFO [Node.<init>] - Binding additional locator mechanisms: id, name

14:00:32.616 INFO [NodeServer$1.start] - Starting registration process for node id a41882b4-4bc8-4075-baf0-680d59a686d6

14:00:32.655 INFO [NodeServer.execute] - Started Selenium node 4.0.0-beta-4 (revision a51085a604): http://172.29.0.3:5555

14:00:32.858 INFO [NodeServer$1.lambda$start$1] - Sending registration event...

14:00:42.883 INFO [NodeServer$1.lambda$start$1] - Sending registration event...

14:00:52.913 INFO [NodeServer$1.lambda$start$1] - Sending registration event...

14:01:02.938 INFO [NodeServer$1.lambda$start$1] - Sending registration event...


Reply all
Reply to author
Forward
0 new messages