accetto / ubuntu-vnc-xfce-g3

Headless Ubuntu/Xfce containers with VNC/noVNC (G3v6).
MIT License
223 stars 63 forks source link

Using remote-debugging-port for chromium #21

Closed IvanMMM closed 2 years ago

IvanMMM commented 2 years ago

Hello How can I use --remote-debugging-port=9222 and expose it to the web? Main idea is to have docker with exposed websocket connection to manipulate it with puppeteer I tried to build my own Dockerfile on top of your image, but it didn't worked :( Any ideas how to make it working?

FROM accetto/ubuntu-vnc-xfce-chromium-g3:latest

EXPOSE 6901
EXPOSE 5901
EXPOSE 9222
CMD ["/usr/bin/chromium-browser", "--remote-debugging-port=9222  --remote-debugging-address=127.0.0.1"]
#CMD ["/usr/bin/chromium-browser", "--remote-debugging-port=9222  --remote-debugging-address=0.0.0.0"] Didn't worked also
accetto commented 2 years ago

Hello,

unfortunatelly I've never tested this particular scenario and I'm not sure if this particular image is ready for it.

I did some quick experiments and I see pretty many error messages. I can provide only a few first thoughts at the moment, but maybe you get some ideas out of it.

After using a Dockerfile like this

FROM accetto/ubuntu-vnc-xfce-chromium-g3:latest
USER 0
EXPOSE 9222
CMD ["/usr/bin/chromium-browser", "--remote-debugging-port=9222 --remote-debugging-address=0.0.0.0 --disable-gpu --headless --no-sandbox"]

you should already get only the error messages like this

[0125/175551.930325:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

DevTools listening on ws://0.0.0.0:9222/devtools/browser/a388e2a6-5cb3-4aca-bd84-22234cfa3296
[0125/175551.949498:ERROR:sandbox_linux.cc(378)] InitializeSandbox() called with multiple threads in process gpu-process.

Maybe it could already work? Please try it and let me know.

However, it could also mean that the dbus configuration in this image is not ready for this.

Regards, accetto

IvanMMM commented 2 years ago

Thank you, man! It worked!

IvanMMM commented 2 years ago

It works fine on my local Mac, but I still have some errors after creating container on Linode (Ubuntu 20.04) Looks like it's somehow related to this bug

[0126/151551.316875:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[0126/151551.316993:ERROR:file_io_posix.cc(144)] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
[23:115:0126/151553.941275:ERROR:chrome_browser_main_extra_parts_metrics.cc(227)] START: ReportBluetoothAvailability(). If you don't see the END: message, this is crbug.com/1216328.
[23:115:0126/151553.941299:ERROR:chrome_browser_main_extra_parts_metrics.cc(230)] END: ReportBluetoothAvailability()
accetto commented 2 years ago

I'm glad it's working.

I'm not familiar with the other errors, but they could be related to the bug you've mentioned, I suppose.

However, it's also true, that the Chromium Browser inside Docker containers always has some limitations and issues. Sometimes you can simply ignore some error messages if they do not do much harm.

It can also be, than some libraries are missing. I try to keep the images as small as possible, so most of stuff is "minimized". You can always add more libraries the standard way. Or you could build a "fat" image by setting the environment variable FEATURES_BUILD_SLIM=0.

Also make sure that you have enough shared memory in the container. Use at least 256MB, it can help. I've described it by the issue #20.

IvanMMM commented 2 years ago

I've found that removing --headless causes this bug. Guys in this thread saying that this bug is fixed in Chromium 98.0.4758.9, so, I guess, we must just wait until it's released in public. I tried different configuration, don't think that something is wrong with you image, I had same result everywhere I tried

accetto commented 2 years ago

That's actually a good news, thanks. :) I always publish new images on Docker Hub as soon as newer Chromium versions are available, so it'll be solved soon, hopefully.

IvanMMM commented 2 years ago

@accetto looks like it's Chromium 98 released. Could you please update your image, so we can check if headless bug is resolved?

accetto commented 2 years ago

@IvanMMM Sorry, I've missed your entry. :( The version 98 is not yet available in the Ubuntu repositories. The latest version there is still 97.0.4692.71-0ubuntu0.18.04.1. I'll update the image when the newer will be available.