devside
devside

Reputation: 2217

Accessing Chrome devtools endpoints running in a docker container from host

Here is my docker-compose.yml

version: '3.8'
services:
  web:
    image: selenium/standalone-chrome:87.0
    tty: true
    command:
        google-chrome --remote-debugging-host=0.0.0.0 --remote-debugging-port=9999 --headless --disable-gpu --no-sandbox --disable-dev-shm-usage --enable-automation --window-size=1440,900 about:blank
    ports:
      - "9999:9999"

Container log:

DevTools listening on ws://127.0.0.1:9999/devtools/browser/a2e16249-bcfe-4dd6-a8d4-b85a7a5077ed

From container:

curl -I http://127.0.0.1:9999/json/list

HTTP/1.1 200 OK
Content-Length:361
Content-Type:application/json; charset=UTF-8

From host:

curl -I http://127.0.0.1:9999/json/list

curl: (52) Empty reply from server

Troubleshooting

I've already tried using localhost, 127.0.0.1 or resolving host ip with host.docker.internal in any ways. If I use a simple http server running on port 9999 then it is well accessible from host.

Upvotes: 1

Views: 2130

Answers (1)

devside
devside

Reputation: 2217

I finally got it worked, I replace "--remote-debugging-host=0.0.0.0" by "--remote-debugging-address=0.0.0.0"

Upvotes: 1

Related Questions