Search code examples

Expose application running on host port to Selenoid

I'm running a Selenoid application test automation script, and would like to run this script against a local application. However, I can't find how to expose my local application (running on port 8787) to Selenoid. I found the following thread discussing a similar issue, but it doesn't solve my issue. The linked thread describes to use the host's ip address. However, I want to make my test system independent. The host ip address is different for each system, and is hard to be retrieved system independently.

I already tried adding the expose field to my docker compose file:

version: '3'
    network_mode: bridge
    image: aerokube/selenoid:latest-release
      - "${PWD}/run:/etc/selenoid"
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "${PWD}/run/video:/opt/selenoid/video"
      - "${PWD}/run/logs:/opt/selenoid/logs"
      - OVERRIDE_VIDEO_OUTPUT_DIR=${PWD}/run/video
      - TZ=Europe/Amsterdam
    command: ["-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video", "-log-output-dir", "/opt/selenoid/logs"]
      - "4444:4444"
      - "8787"

However, this doesn't work because the docker containers created by Selenoid do not get passed the same option.

Is there any way to expose my host port 8787 to my Selenoid container in a system/os independent way (either via a configuration in the docker-compose.yml file, a capability passed to the remote driver or any other way?)?


  • Selenoid runs browsers in standard Docker containers, so anything applicable to Docker is applicable to Selenoid browsers. Docker was created for the case when all interacting parts are packed to containers and in that case you have legacy Docker links or modern Docker custom networks on your service. If you still want to run your application on the host machine without packing it to container, you have to either user host machine IP or on some platforms Docker provides a particular domain name, e.g. docker.for.mac.localhost on Mac.