4

I have a very simple docker container that installs 'google-chrome-stable' by following these instructions.

Inside the container, I can't start and access the debug server:

# start chrome in debug mode
$ google-chrome-stable --no-sandbox --remote-debugging-port=9222

# verify that I can reach the debugging server
$ curl 127.0.0.1:9222
curl: (7) Failed to connect to localhost port 9222: Connection refused

Outside the container (OSX 10.12.6), the same process works fine:

# start chrome in debug mode
$ chrome --no-sandbox --remote-debugging-port=9222

# verify that I can reach the debugging server
$ curl localhost:9222
curl localhost:9222
<html>
<head>
<title>Inspectable pages</title>
...

There must be something I'm missing because it seems like these are identical workflows even though the environments are different.

Can someone illuminate what's going on here?

:: update with more debug info ::

Running the command with --enable-logging --v=1 flags, I get these logs [none of which seem remarkable]:

[64:64:0118/111557.689426:VERBOSE1:breakpad_linux.cc(1980)] Breakpad disabled
[72:72:0118/111557.718821:VERBOSE1:zygote_main_linux.cc(594)] ZygoteMain: initializing 2 fork delegates
[72:72:0118/111557.719320:VERBOSE1:nacl_fork_delegate_linux.cc(146)] NaClForkDelegate::Init()
[72:72:0118/111557.724777:VERBOSE1:nacl_fork_delegate_linux.cc(146)] NaClForkDelegate::Init()
[72:72:0118/111557.728735:VERBOSE1:zygote_main_linux.cc(362)] Unable to load plugin internal-not-yet-present internal-not-yet-present: cannot open shared object file: No such file or directory
[72:72:0118/111557.729441:INFO:cpu_info.cc(50)] Available number of cores: 4
[64:64:0118/111557.731729:WARNING:browser_main_loop.cc(297)] Gtk: cannot open display:

Running netstat shows nothing either:

$ netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
Thomas
  • 5,736
  • 8
  • 44
  • 67
  • are you running the google-chrome-stable and curl commands from the same container? Or are you running the curl from your host machine? – whites11 Jan 18 '18 at 10:39
  • Oooh, I can see a typo, you're exposing port 9222 but curling port 7222 ! – whites11 Jan 18 '18 at 10:41
  • @whites11 Both commands in the same container. Apologies for the typo, this is all over port 9222. Updating the question... – Thomas Jan 18 '18 at 11:03
  • That's kinda weird then, is it possible to see some debugging data from the google-chrome-stable command? Also, what does `netstat -ntpl` return? – whites11 Jan 18 '18 at 11:06
  • @whites11 updated! thanks. – Thomas Jan 18 '18 at 11:22
  • Chrome is not listening to port 9222 for some reason. It might be because of `Gtk: cannot open display:`. You could try running x11 inside the container. Take a look here: https://stackoverflow.com/questions/16296753/can-you-run-gui-apps-in-a-docker-container – whites11 Jan 18 '18 at 11:26

1 Answers1

4

It turns out what I was doing won't work without the --headless flag.

# start chrome in debug mode
$ google-chrome-stable --no-sandbox --remote-debugging-port=9222 --headless

# debugging server works as expected
$ curl 127.0.0.1:9222
<html>
<head>
<title>Inspectable pages</title>
...
Thomas
  • 5,736
  • 8
  • 44
  • 67