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.

Unpredictable behavior of Lighthouse 4.3.1/5.1.0 in docker container

See original GitHub issue

Provide the steps to reproduce

  1. Run LH on <affected url>

What is the current behavior?

I am trying to run lighthouse from inside Docker container and I am seeing strange unpredictable behavior when executing the following command in bash (after getting inside): lighthouse --disable-storage-reset --output=json --no-enable-error-reporting --chrome-flags="--no-sandbox --headless --disable-gpu" https://www.agencjawhites.pl

I build two docker containers with different versions of nodejs and lighthouse. The first one has nodejs==10.16.0, google-chrome==75.0.3770.100, lighthouse==5.1.0

FROM ubuntu:bionic

# install node js
RUN apt-get update \
    && apt-get install -y \
    build-essential \
    make \ 
    curl \
    ca-certificates \
    apt-transport-https \
    lsb-release \
    gnupg

# install google-chrome
RUN curl -sL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o google-chrome-stable.deb \
    && apt-get install -y ./google-chrome-stable.deb 

# create user
# Add Chrome as a user
RUN groupadd -r chrome && useradd -r -g chrome chrome \
    && mkdir /home/chrome && chown -R chrome:chrome /home/chrome

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
    && apt-get install -y nodejs 

# install lighthouse
RUN npm install -g lighthouse@5.1.0

WORKDIR /home/chrome

# Run Chrome non-privileged
USER chrome

The second one has nodejs==8.16.0, google-chrome==75.0.3770.100, lighthouse==4.3.1

FROM ubuntu:bionic

# install node js
RUN apt-get update \
    && apt-get install -y \
    build-essential \
    make \ 
    curl \
    ca-certificates \
    apt-transport-https \
    lsb-release \
    gnupg

# install google-chrome
RUN curl -sL https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -o google-chrome-stable.deb \
    && apt-get install -y ./google-chrome-stable.deb 

# create user
# Add Chrome as a user
RUN groupadd -r chrome && useradd -r -g chrome chrome \
    && mkdir /home/chrome && chown -R chrome:chrome /home/chrome

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - \
    && apt-get install -y nodejs 

# install lighthouse
RUN npm install -g lighthouse@4.3.1

WORKDIR /home/chrome

# Run Chrome non-privileged
USER chrome

My docker version: Docker version 18.09.7, build 2d0083d

I am running the same lighthouse command (stated earlier) in both containers against the https://www.agencjawhites.pl (which has redirect). Sometimes lighthouse==5.1.0 finishes without errors, but sometimes hangs (see screenshot) and produces errors. The same things happens with ligthouse==4.3.1. Sometimes it gives full report but sometimes it produces errors. I am not seeing any pattern so that is why it is unpredictable. I have no idea what might be causing this. I have ligthouse==4.3.1 installed on my local computer (linux mint tara, nodejs==8.12.0, google-chrome==75.0.3770.100) and each time I run lighthouse it finishes without errors, whereas in docker it is a lottery. I wanted to run lighthouse on Kubernetes Pod, but right now with such unpredictable behavior it is not an option. Any ideas what might be causing this? I collected a few screenshots with errors: lighthouse lighthouse1 lighthouse2

What is the expected behavior?

Environment Information

  • Affected Channels:
  • Lighthouse version:
  • Node.js version:
  • Operating System:

Related issues

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
skadegladcommented, Jul 2, 2019

Might be not related, but to stop chrome from crashing in docker-selenium containers, it is generally required to use host’s shared memory (either via mounting /dev/shm or via a flag --shm-size=2g ) see: https://github.com/SeleniumHQ/docker-selenium#running-the-images

1reaction
dkajtochcommented, Jul 24, 2019

I performed tests on more than 50 thousand different urls and lighthouse was responsive thanks to @skadeglad solution. Flag --shm-size=2g works for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Compose release notes
Recovered behavior for 'compose up -d' of recreating containers of compose ... with a version of Compose earlier than 1.23.0 would cause unexpected...
Read more >
gitlab-runner 15.1.0 regresses docker-in-docker service health ...
This behaviour/bug leads to ~30s delay and additional 100 log lines for each job using this service. But the jobs still work as...
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