question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support launching in Docker

See original GitHub issue

We have a CI environment at my company that does not have chrome nor allows apt-get install on our machines, but docker is available for better isolation of these dependencies, but I see no documentation or support for Docker. This would be greatly appreciated. I’m trying to get a shell script put together that can achieve this by passing in as a CHROME_PATH, which may be the best, most unobtrustive way to support it. I’m struggling to get it working though 😕

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:13

github_iconTop GitHub Comments

4reactions
kyasbalcommented, Feb 12, 2020

I struggled with the relevant issue for a while.

This is my code to launch Chrome in headless mode in Docker.

function getChromeFlags(resolution: Resolution2D) {
  let appendedOptions = headless ? ["--headless", "--disable-gpu"] : [];
  return [
    `--window-size=${resolution.width},${resolution.height}`,
    ...appendedOptions
  ];
}
const chrome = await ChromeLauncher.launch({
  startingUrl: url,
  chromeFlags: getChromeFlags(resolution)
});

Then I got this error.

{ Error: connect ECONNREFUSED 127.0.0.1:46803
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 46803 }

I tried to use puppeteer workaround that @jakelacey2012 suggested. But actually that won’t work for me.

I could solve this problem by adding --no-sandbox flag as chromeFlags in the launch option.

I hope this workaround is still safe for most of CI use case.

1reaction
patrickhulcecommented, Feb 12, 2020

@kyasbal-1994 the lighthouse-ci docs have a decent explanation of the tradeoffs involved in --no-sandbox and the different workarounds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to automatically start a service when running a docker ...
Just put it alongside your Dockerfile. Then in your Dockerfile you should have an instruction that copies this file to the desired location....
Read more >
docker start
docker start : Start one or more stopped containers.
Read more >
Get support
Docker offers support for developers subscribed to a Pro, Team, or a Business tier. ... Installation crashes; Failure to launch Docker Desktop on...
Read more >
Containerize an application
Start your container using the docker run command and specify the name of the image you just created: $ docker run -dp 3000:3000...
Read more >
Quick Start Guide and sign in | Docker Documentation
Go to the Docker Desktop menu and then select Sign in / Create Docker ID. · Enter your Docker ID and password and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found