Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Headless chromium in ubuntu docker container

I am trying to run a headless instance of chromium within an ubuntu docker image but I keep getting the error this system has no display nor audio inputs or outputs

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

Is there anyway to disable dbus as it seems docker does not support it here are lines from my Dockerfile

FROM arm64v8/ubuntu:bionic
RUN apt install -y chromium-browser
RUN apt install -y chromium-drivers

Here is the launch line I use

chromium-browser --no-sandbox --headless --autoplay-policy=no-user-gesture-required --no-first-run --disable-gpu --use-fake-ui-for-media-stream --use-fake-device-for-media-stream --disable-sync index.html
like image 509
maxwellpwang Avatar asked Mar 07 '21 00:03

maxwellpwang


People also ask

Does Chromium support headless?

Headless Chromium allows running Chromium in a headless/server environment. Expected use cases include loading web pages, extracting metadata (e.g., the DOM) and generating bitmaps from page contents -- using all the modern web platform features provided by Chromium and Blink.

How do you run a puppeteer and headless Chrome in a Docker container?

Using Puppeteer in Dockerconst puppeteer = require("puppeteer"); const browser = await puppeteer. launch({ headless: true, args: [ "--disable-gpu", "--disable-dev-shm-usage", "--disable-setuid-sandbox", "--no-sandbox", ] }); const page = await browser. newPage(); await page.

How do I run a Docker Chromium?

Launch from KDE Start Menu: Internet -> Chromium Docker, and after a terminal window flashes on screen and a few seconds pass, Docker will launch with Chromium Media Edition within it. Happy Streaming!


1 Answers

To have real headless chromium you will need to add the --remote-debugging-port option to your line as follows:

chromium-browser --no-sandbox --headless --autoplay-policy=no-user-gesture-required --no-first-run --disable-gpu --use-fake-ui-for-media-stream --use-fake-device-for-media-stream --disable-sync --remote-debugging-port=9222 index.html

After launching, you can use the debugging port to connect and control the browser as described here

like image 109
jordanvrtanoski Avatar answered Oct 22 '22 20:10

jordanvrtanoski