How to connect to a Docker container?

As part of a GitHub action I would like to run a line like

docker run -d -p 4444:4444 --name selenium selenium/standalone-chrome

and then having it accessible to my application,

response ="$host:4444/wd/hub/session",
                     [("Content-Type" => "application/json")],
		     JSON3.write(Dict("desiredCapabilities" => wd.capabilities,

Currently, I get the following error using either

host = "localhost"


host = "host.docker.internal"

I have been looking at a few related posts (MySQL connection from Docker action?, Docker container not mapping to correct port - connection refused, Communicate from service BACK to job container), but haven’t been able to figure out the exact changes to make it work. I have tried with the container name and network alias as well.

Hi, I replied in a different thread but will paste my comment here as well:


You could run the webdriver as a service container, in which case youd do something like:

    image: selenium/standalone-chrome


That way a docker network will be created, and from inside a container action, you can connect to it via the hostname “selenium” (comes from the service name). So youd just use hostname=selenium, port=4444

Note that in the above example, no port mapping were specified, thats because for user defined bridge networks in docker, all ports are accesible by default, so the application inside the container only needs to actually be listening on 4444

We dont currently support adding docker-specific options, like “network”, when running container actions so unfortunately you wouldnt be able to create a network, and run your action attached to that network specifically (something like docker run --network …)

Of course if you are using a javascript action that would be running on the host, so you could connect via localhost (if you ran the selenium container with --network host)

Hope that helps

1 Like

Thanks! That helped me better understand the service example-services.

I had some issues with the VM way, but the container one worked great. Here is my final workflow file.

name: CI

on: push

    container: node:current
        image: selenium/standalone-chrome
        options: --health-cmd '/opt/bin/'
    runs-on: ${{ matrix.os }}
        julia-version: [1.3.0]
        julia-arch: [x64]
        os: [ubuntu-latest]
      - uses: actions/checkout@v1.0.0
      - uses: julia-actions/setup-julia@latest
          version: ${{ matrix.julia-version }}
      - uses: julia-actions/julia-buildpkg@latest
      - uses: julia-actions/julia-runtest@latest
      - uses: julia-actions/julia-uploadcodecov@latest
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
      - uses: julia-actions/julia-docdeploy@releases/v1
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}