Run a NOT headless chrome on a docker container

Bishok picture Bishok · Dec 27, 2018 · Viewed 11.2k times · Source

Running chrome on docker machines is only possible when chrome is headless. Unfortunately, headless chrome can't ignore certificate errors which prevents my tests from running.

I'm trying to run an already working NodeJS e2e test environment on a docker container. Most of the tests pass but when a site requires a certificate it can't be accessed. On none headless chrome I can simply ignore the certification error. The base docker image installed on the container is Node:8

{
 browserName: 'chrome',
 chromeOptions: {
   binary: puppeteer.executablePath(),
   args: [
     '--lang=en-US','--headless','--no-sandbox','--ignore-certificate-errors'
   ]
}

The expected result is to either run chrome with gui on a docker container or somehow ignore the server certificate errors in headless chrome.

Answer

mentallurg picture mentallurg · Dec 27, 2018

Use Xvfb. This will allow you to use Chrome with GUI.

The idea is simple: you use virtual desktop. Configuring multiple desktops / displays on a standalone VM took some efforts. With Docker it is simple.

Some examples:

http://www.mattzeunert.com/2018/07/21/running-headful-chrome-on-ubuntu-server.html

https://medium.com/dot-debug/running-chrome-in-a-docker-container-a55e7f4da4a8