-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't run Puppeteer Sharp in Docker #262
Comments
You won't be able to run Chrome inside docker. You'd need to use some solution like browserless.io. |
@kblok, can you please explain(or give references) why this is so ? |
@respel long story short, a Docker container doesn't have all the dependencies a browser needs to run. You can try to make this like this https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#running-puppeteer-in-docker or this https://github.com/c0b/chrome-in-docker Let me know how it goes if you go that way. |
@kblok , thanks for the help but I need it specifically for a windows container. |
I'll try to dig a little bit into it. It would be great to know how to support this. |
I was able to get it running easily in docker linux. I had to set execute permissions after I downloaded.
|
Im using puppeteer nugetpackage 1.9.0. I also had the same issue that browser couldn't launch in my linux container. I added this line in my dockerfile and it fixed the problem for me: apt-get install -y wget unzip fontconfig locales gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget reference: |
@DdannyB are you confirming that you managed to run pptr# on Docker? Would you mind sharing some dockerfile here? |
This is what I used in my dockerfile for installing the dependencies for chrome/puppeteer:
and this is the code I used to warmup chrome:
The only "problem" I had so far is it didnt install some fonts for example calibri but i'm looking into that. |
Can you please tell me, is it works with Headfull in the container? Like Headless = false; |
I don't know for sure but my guess would be it would still work, I think it would only be a difference in performance because when headless is true it will not launch a full version of a browser. This is a quote I found: i haven't tested it so i don't know for sure! |
For the record I was able to make it work just via:
(in my Dockerfile) and:
in my launch code. |
now aday. You need install these package. so this is the dockerfile need include FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim as runtime RUN apt-get update && apt-get install -y libx11-6 libx11-xcb1 libatk1.0-0 libgtk-3-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 libcairo2 libasound2 libxshmfence1 libnss3 |
Update 2023 (.NET 7): this solution worked under
and PDFs started to generate |
using var browser = await Puppeteer.LaunchAsync(new LaunchOptions
While building the image there is no issue in cmd but when I run the image then a issue is raised that shows Unhandled exception. System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'D:\Saqib\Downloads\chrome-win\chrome.exe' with working directory '/'. No such file or directory //My Docker file Install dependenciesRUN apt-get update && apt-get install -y wget Install Node.js and npmRUN apt-get install -y curl Install Google ChromeRUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb Install PuppeteerRUN npm init -y Add a user so you don't need --no-sandboxRUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser Copy your application filesCOPY bin/Release/net6.0/publish . Set the entry point for your applicationENTRYPOINT ["dotnet", "PupeeterSharpGmailAutomation.dll"] Q: Can anyone tell me how to solve it? |
If you're using Azure App Service for Linux (Built-in images) without a custom Docker image, you can specify this as the
Azure Portal ref: |
Args = new string[] { "--no-sandbox" } worked for me both linux and windows await new BrowserFetcher().DownloadAsync(); Header ",FooterTemplate = " Page of "}; var pdfStream = await page.PdfStreamAsync(pdfOptions); await browser.CloseAsync(); using (MemoryStream ms = new MemoryStream()) |
Description
I am not able to run Puppeteer Sharp in a Windows docker container. It gives an error while trying to launch chromium.
Complete minimal example reproducing the issue
Actual behavior:
Versions
Docker
Dotnet
Additional Information
Publish
Dockerfile
The text was updated successfully, but these errors were encountered: