diff --git a/NodeDocker/Dockerfile b/NodeDocker/Dockerfile index 7afea04fdd..0a069abcd8 100644 --- a/NodeDocker/Dockerfile +++ b/NodeDocker/Dockerfile @@ -22,10 +22,11 @@ USER ${SEL_UID} EXPOSE 4444 COPY --chown="${SEL_UID}:${SEL_GID}" start-selenium-grid-docker.sh \ - config.toml \ start-socat.sh \ /opt/bin/ +COPY --chown="${SEL_UID}:${SEL_GID}" config.toml /opt/selenium/ + COPY selenium-grid-docker.conf /etc/supervisor/conf.d/ ENV SE_OTEL_SERVICE_NAME="selenium-node-docker" diff --git a/NodeDocker/start-selenium-grid-docker.sh b/NodeDocker/start-selenium-grid-docker.sh index 46e829cee5..ac03474a01 100755 --- a/NodeDocker/start-selenium-grid-docker.sh +++ b/NodeDocker/start-selenium-grid-docker.sh @@ -106,5 +106,5 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \ --subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \ --bind-host ${SE_BIND_HOST} \ --detect-drivers false \ - --config /opt/selenium/config.toml \ + --config /opt/selenium/${SE_NODE_DOCKER_CONFIG_FILENAME:-"config.toml"} \ ${SE_GRID_URL} ${SE_OPTS} diff --git a/README.md b/README.md index fbb035fa9a..115a833f39 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Talk to us at https://www.selenium.dev/support/ * [Video recording and uploading](#video-recording-and-uploading) * [Dynamic Grid](#dynamic-grid) * [Configuration example](#configuration-example) + * [Share volumes config of Dynamic Grid container to node browser containers](#share-volumes-config-of-dynamic-grid-container-to-node-browser-containers) * [Execution with Hub & Node roles](#execution-with-hub--node-roles) * [Execution with Standalone roles](#execution-with-standalone-roles) * [Using Dynamic Grid in different machines/VMs](#using-dynamic-grid-in-different-machinesvms) @@ -745,6 +746,36 @@ With the optional config key `host-config-keys` under section [docker] in a conf Valid key names for Docker host config can be found in the Docker API [documentation](https://docs.docker.com/engine/api/latest/#tag/Container/operation/ContainerCreate) or via the command `docker inspect` the node-docker container. +### Share volumes config of Dynamic Grid container to node browser containers + +In case you want to access download directory in node browser containers (e.g `/home/seluser/Downloads`) via volumes config of Dynamic Grid container, you can add the following config to the `config.toml` file + +```toml +[docker] +host-config-keys = ["Binds"] +``` + +Volumes config in docker compose file + +```dockerfile +services: + node-docker: + image: selenium/node-docker:latest + volumes: + - ./assets:/opt/selenium/assets + - ./config.toml:/opt/selenium/docker.toml + - ./downloads:/home/seluser/Downloads + - /var/run/docker.sock:/var/run/docker.sock + environment: + - SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml +``` + +`/opt/selenium/config.toml` is the default path for the config file in all images. Once volumes config is shared to node browser containers, its `config.toml` could be overwritten by node-docker container config file. + +In this case, mount your `config.toml` file to `/opt/selenium/docker.toml` in node-docker container. And set the environment variable `SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml` to specify that config file name for the startup script. + +Refer to example [docker-compose-v3-test-node-docker.yaml](./tests/docker-compose-v3-test-node-docker.yaml) + ### Execution with Hub & Node roles This can be expanded to a full Grid deployment, all components deployed individually. The overall diff --git a/tests/docker-compose-v3-test-node-docker.yaml b/tests/docker-compose-v3-test-node-docker.yaml index ca6776db7a..a06a3afed8 100644 --- a/tests/docker-compose-v3-test-node-docker.yaml +++ b/tests/docker-compose-v3-test-node-docker.yaml @@ -4,7 +4,7 @@ services: image: ${NAMESPACE}/node-docker:${TAG} volumes: - ./videos:/opt/selenium/assets - - ./videos/config.toml:/opt/selenium/config.toml + - ./videos/config.toml:/opt/selenium/docker.toml - /var/run/docker.sock:/var/run/docker.sock - ./videos/Downloads:/home/seluser/Downloads dns: @@ -16,6 +16,7 @@ services: depends_on: - selenium-hub environment: + - SE_NODE_DOCKER_CONFIG_FILENAME=docker.toml - SE_EVENT_BUS_HOST=selenium-hub - SE_EVENT_BUS_PUBLISH_PORT=4442 - SE_EVENT_BUS_SUBSCRIBE_PORT=4443