Hi All,
We are using Chromium's headless mode to convert HTML to PDF documents and images. When running the HTML to PDF conversion inside a Windows Docker container, Chromium fails to launch and crashes during initialization. As a result, the conversion process does not complete successfully in this environment.
Please take a look at the Docker file below.
# This stage is used when running from VS in fast mode (Default for Debug configuration)FROM mcr.microsoft.com/dotnet/aspnet:8.0-nanoserver-1809 AS baseWORKDIR /appEXPOSE 8080EXPOSE 8081# This stage is used to build the service projectFROM mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-1809 AS buildARG BUILD_CONFIGURATION=ReleaseWORKDIR /srcCOPY ["HTMLtoPDF_ASP_NET_Core_Windows_Docker/HTMLtoPDF_ASP_NET_Core_Windows_Docker.csproj", "HTMLtoPDF_ASP_NET_Core_Windows_Docker/"]RUN dotnet restore "./HTMLtoPDF_ASP_NET_Core_Windows_Docker/HTMLtoPDF_ASP_NET_Core_Windows_Docker.csproj"COPY . .WORKDIR "/src/HTMLtoPDF_ASP_NET_Core_Windows_Docker"RUN dotnet build "./HTMLtoPDF_ASP_NET_Core_Windows_Docker.csproj" -c %BUILD_CONFIGURATION% -o /app/build# This stage is used to publish the service project to be copied to the final stageFROM build AS publishARG BUILD_CONFIGURATION=ReleaseRUN dotnet publish "./HTMLtoPDF_ASP_NET_Core_Windows_Docker.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)FROM base AS finalWORKDIR /appCOPY --from=publish /app/publish .ENTRYPOINT ["dotnet", "HTMLtoPDF_ASP_NET_Core_Windows_Docker.dll"]How to launch Chromium with headless mode in a Windows Docker container?
Regards,
Karmegam S