Can't run Puppeteer Sharp in Docker
See original GitHub issueDescription
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
var options = new LaunchOptions
{
Headless = true
};
Console.WriteLine("Downloading chromium");
await Downloader.CreateDefault().DownloadRevisionAsync(Downloader.DefaultRevision);
Console.WriteLine("Navigating google");
using (var browser = await Puppeteer.LaunchAsync(options, Downloader.DefaultRevision))
using (var page = await browser.NewPageAsync())
{
await page.GoToAsync("http://www.google.com");
Console.WriteLine("Generating PDF");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), "google.pdf"));
Console.WriteLine("Export completed");
Console.ReadLine();
}
Actual behavior:
Downloading chromium
Navigating google
Unhandled Exception: PuppeteerSharp.ChromeProcessException: Failed to create connection ---> PuppeteerSharp.ChromeProcessException: Failed to launch chrome!
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PuppeteerSharp.Launcher.<LaunchAsync>d__16.MoveNext()
--- End of inner exception stack trace ---
at PuppeteerSharp.Launcher.<LaunchAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PuppeteerSharpTest.Program.<MainAsync>d__1.MoveNext() in C:\Users\xxx\source\repos\PuppeteerSharpTest\PuppeteerSharpTest\Program.cs:line 27
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at PuppeteerSharpTest.Program.Main(String[] args) in C:\Users\xxx\source\repos\PuppeteerSharpTest\PuppeteerSharpTest\Program.cs:line 13
Versions
Docker
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:12:48 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.24)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:21:42 2018
OS/Arch: windows/amd64
Experimental: false
Dotnet
.NET Command Line Tools (2.1.200)
Product Information:
Version: 2.1.200
Commit SHA-1 hash: 2edba8d7f1
Runtime Environment:
OS Name: Windows
OS Version: 10.0.15063
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.200\
Microsoft .NET Core Shared Framework Host
Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11
Additional Information
Publish
dotnet publish -o out
Dockerfile
FROM microsoft/aspnetcore
WORKDIR /app
COPY out/ .
ENTRYPOINT ["dotnet", "PuppeteerSharpTest.dll"]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Running Puppeteer-Sharp on Docker | Darío Kondratiuk
Fixed it, there is an issue because of puppeteer recipe was placed at wrong place so moved recipe inside final stage in build...
Read more >How to get Puppeteer-Sharp working on an AWS Elastic ...
I'm looking for an up-to-date example of how to get PuppeteerSharp running on an AWS Elastic Beanstalk instance running Docker (.
Read more >How to use Puppeteer inside a Docker container
I have been trying to run @unlighthouse and Puppeteer in a docker for two days now, with nothing working. I installed Chrome in...
Read more >Running Puppeteer under Docker
I recently tried to dockerise an old hobby project and unsurprisingly, a couple of things broke. Some of these were fairly simple fixes...
Read more >Running Puppeteer-Sharp on Docker - DevPress官方社区
I get many questions about running Puppeteer-Sharp on Docker. Let's see if we can get a: Let's take a look at the example...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For the record I was able to make it work just via:
(in my Dockerfile) and:
in my launch code.
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.