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.

Exception when downloading chrome in docker

See original GitHub issue

Hi,

I am trying to run puppeteer sharp in docker (I know it is not fully supported but I found some posts where people made it work) but every time I try to download the browser I get the following exception:

Exception when downloading the browser: System.DllNotFoundException: Unable to load shared library 'MonoPosixHelper' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libMonoPosixHelper: cannot open shared object file: No such file or directory
   at PuppeteerSharp.Helpers.Linux.LinuxSysCall.FromFilePermissions(FilePermissions value, UInt32& rval)
   at PuppeteerSharp.BrowserFetcher.DownloadAsync(Int32 revision)
   at ADM.Jobs.Program.Main(String[] args) in /usr/src/jobs/Program.cs:line 18

This is probably not an issue in PuppeteerSharp, but I was wondering if someone had the same issue and knows how to solve it.

This is the code I am using

try
{
    await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
}
catch (Exception e)
{
    Console.WriteLine($"Exception when downloading the browser: {e}");
    throw;
}
Console.WriteLine("Browser downloaded!");

and this is the docker file:

FROM microsoft/dotnet:latest
WORKDIR /usr/src
COPY . ./
RUN dotnet build
RUN dotnet publish -o app
ENTRYPOINT ["dotnet", "app/Test.dll"]

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
scabanacommented, Apr 8, 2019

Resolved by https://github.com/kblok/puppeteer-sharp/issues/1035

As for the docker part, you’ll need something like this:

RUN apt-get update \
	&& apt-get install -yq libgconf-2-4 \
	&& apt-get install -y gnupg2

#disable this when there's a version of puppeteer-sharp that supports not having mono is released
RUN apt-get install -y apt-transport-https dirmngr gnupg ca-certificates \
	&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
	&& echo "deb https://download.mono-project.com/repo/debian stable-stretch main" | tee /etc/apt/sources.list.d/mono-official-stable.list \
	&& apt-get update \
	&& apt-get install -y mono-complete

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.

RUN apt-get update && apt-get install -y wget --no-install-recommends \
    && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && sh -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
    && apt-get update \
    && apt-get install -y google-chrome-unstable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst ttf-freefont --no-install-recommends \
    && rm -rf /var/lib/apt/lists/* \
    && apt-get purge --auto-remove -y curl \
    && rm -rf /src/*.deb 

And add your docker stuff after

2reactions
kblokcommented, Apr 8, 2019

I don’t think it’s something Puppeteer-Sharp should do. We could create a Docker image with this setting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to install Google chrome in a docker container
There are actually two ways to install Chrome on a docker container: If you download the deb file manually, you can install it...
Read more >
Chrome Installation could not be found in docker image ...
Chrome does not seem to be installed even though there are no error messages when running on docker build or it is possible...
Read more >
selenium/standalone-chrome-debug can't download files
One of the test should download a few files, store it in the specified volume folder and then check if that file exist...
Read more >
[Code example]-Chrome download failed in Selenium docker
I'm trying to download a file with Selenium running on docker and getting the error Failed - insufficient permissions as can be seen...
Read more >
Selenium webdriver, chromedriver and chrome with docker ...
I have the following error after configuring a custom docker image for my spider selenium.common.exceptions.WebDriverException: Message: unknown error: ...
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