

Because Headless was a separate implementation, it had its own bugs and features that weren’t present in headful Chrome. It doesn’t share any of the Chrome browser code in //chrome.Īs you might imagine, implementing and maintaining this separate Headless browser came with a lot of engineering overhead - but that wasn’t the only problem.

Technically, the old Headless was a separate, alternate browser implementation that happened to be shipped as part of the same Chrome binary. Perhaps surprisingly, this wasn’t actually true. The command-line snippet we showed earlier uses the -headless command-line flag, suggesting that Headless is just a mode of operation of the regular Chrome browser. Here’s a minimal command-line example of using Headless mode to create a PDF file of a given URL: chrome -headless -print-to-pdf # What’s new in Headless?īefore we dive into the recent Headless improvements, it’s important to understand how the “old” Headless worked. Headless mode is a popular choice for browser automation through projects like Puppeteer or ChromeDriver.

Essentially, running Chrome without chrome! # Backgroundīack in 2017, Chrome 59 introduced the so-called Headless mode, which lets you run the browser in an unattended environment without any visible UI.

You should find Puppeteer executes successfully, provided proper Chrome flags are used.Chrome’s Headless mode just got a whole lot better! This article presents an overview of recent engineering efforts to make Headless more useful for developers by bringing Headless closer to Chrome’s regular “headful” mode. Chrome will write into /tmp instead.Īdd your JavaScript to your container with a COPY instruction. disable-dev-shm-usage – This flag is necessary to avoid running into issues with Docker’s default low shared memory space of 64MB.If you’re uncomfortable with this, you’ll need to manually configure working Chrome sandboxing, which is a more involved process. It’s vital you ensure your Docker containers are strongly isolated from your host. Using these flags could allow malicious web content to escape the browser process and compromise the host. no-sandbox and disable-setuid-sandbox – These disable Chrome’s sandboxing, a step which is required when running as the root user (the default in a Docker container).Setting this flag explicitly instructs Chrome not to try and use GPU-based rendering. disable-gpu – The GPU isn’t usually available inside a Docker container, unless you’ve specially configured the host.
